?

Log in

No account? Create an account

Previous Entry | Next Entry

.NET interview questions: - What is the difference between arraylist and list? Are Arraylist faster or Arrays?

Difference between arraylist and list: -

  • Arrays are fixed in size while Arraylist is resizable.

  • Arrays are strongly typed, in other words when you create an array it can store only one data type data. Arraylist can store any datatype.

Are Arraylist faster or Arrays: -

Array list takes any data type which leads to boxing and unboxing. As arrays are strongly typed they do not do boxing and unboxing. So arrays are faster as compared to array list.

// Array definition
int[] str = new int[10];

// Array list definition
ArrayList MyList = new ArrayList();


Generic equivalent for array list, stack, queues and hashtable: -

Below are the listed generic equivalents for each of them:-

  • Array list generic equivalent is List<int>.

  • Stack generic equivalent is Stack<int>.

  • Queue generic equivalent is Queue<int>.

  • Hashtable generic equivalent is Dictionary<int,int>.

Also see .NET interview questions video on different types of collection in .NET and C#: -

Copy right www.questpond.com

Tags

Latest Month

September 2017
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
Powered by LiveJournal.com