Difference between array, arraylist, List, Hashtable, Dictionary and SortedList in c#

Basic difference is that arrays are of fixed size. Whereas an ArrayList implements the list data structure and can dynamically grow. While arrays would be more performance that a list, a list would be far more flexible since you don't need to know the required size initially. Array - represents an old-school memory array - kind of like a alias for a normal type[] array. Can enumerate. Can't grow automatically. I would assume very fast insertion, retrieve and speed. ArrayList - automatically growing array. Adds more overhead. Can enum., probably slower than a normal array but still pretty fast. These are used a lot in .NET List - one of my favorites - can be used with generics, so you can have a strongly typed array, e.g. List . Other than that, acts very much like ArrayList. Hashtable - plain old hashtable. O(1) to O(n) worst case. Can enumerate the value and keys properties, and do key/val pairs. Dictionary - same as above only strongly typed via generics, such a...

What is difference between Data list, Grid view and Repeater in asp.Net?

All these controls have many things in common like Data Source Property, Data Bind Method ItemDataBound and ItemCreated.
When Data Source Property of a Grid view is assigned to a Dataset then each Data Row present in the Data Row Collection of Data Table is assigned to a corresponding DataGridItem and this is same for the rest of the two controls also. But The HTML code generated for a Grid view has an HTML TABLE element created for the particular Data Row and it’s a Table form representation with Columns and Rows.
For a Data list it’s an Array of Rows and based on the Template Selected and the RepeatColumn Property value we can specify how many Data Source records should appear per HTML
row. In short in Grid view we have one record per row, where as in data list we can have five or six rows per row.  

In Repeater Control the data records which are to be displayed depends upon the Templates specified and the only HTML generated is the due to the Templates.

  • GridView provides ability to allow the end-user to edit the page data or sort the page records. But it comes at a cost of speed. Secondly, the display format is very simple i.e. is in row and columns.
  • With its templates, DataList provides more control over the look and feel of the displayed data than the GridView. And it offers better performance than GridView.
  • With Repeater, the only HTML emitted are the values of the databinding statements in the templates along with the HTML markup specified in the templates—no "extra" HTML is emitted, as with the Gridview and DataList.

Comments

Popular posts from this blog

C# Interview Questions on Inheritance

C# Interview Questions on value types and reference types

Why to use UpdatePanel control in AJAX ASP.NET?