Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A
dotnetinter

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

.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#: -

Tags: .net, .net interview questions, arraylist, arrays, c#, csharp interview questions, it interview questions with answers, list, programming interview questions
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments