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

What is the difference between Array, ArrayList and List?( .Net Interview questions)

This youtube video created by www.questpond.com demonstrates different collection in .NET



First of all, all of them are used when we want to store more than one values but want to create one variable.

Arrays

  • Disadvantages

             o    Array is a fixed sized data structure. We cannot change the length of an array once it is created.
             o    Array requires continuous memory blocks.


  • Advantages

             o   Array is type safe (strongly type).

Array List

  • Disadvantages

             o    It’s not type safe.
             o    Performance wise not good because every time we add some value inside it, automatic boxing will
                   performed (value will converted to object) and every time we want to retrieve something from it we
                   have to explicitly perform unboxing(convert object back to value).

  • Advantages

             o    Dynamic size – With every new addition and removal of item, size of a data structure changes.
             o    Won’t require continuous memory allocation.

List

  • Advantages

            o    Strongly typed
            o    Dynamic size
            o    Won’t require continuous memory allocation.

If you are working on .net 2.0 or higher you should always go with List instead of Array List or Array.

One more most ask .NET interview question is around Generics see the below video for the same.



If you are looking for some live hardcore training on MVC, WCF, Design Patterns, BI, WPF, UML visit www.sukesh-marla.com or contact SukeshMarla@Gmail.com
Tags: .net collection interview questions, c# arraylist interview questions, c# arrays interview questions, c# collection interview questions, c# generics interview questions, csharp interview questions, it interview questions with answers, 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