Q:

What is the difference between Array and Arraylist?

0

What is the difference between Array and Arraylist?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

There are some differences between a ref and an out that I have arranged in a table for easier comparison:

Array ArrayList
An Array is strongly-typed. We can store only the same type of data. ArrayList is a non-generic collection type. ArrayList’s internal Array is of the object type. So, we can store multiple types of data in ArrayList.
Array stores a fixed number of elements. ArrayList is dynamic in terms of capacity. If the number of elements exceeds, ArrayList will increase to double its current size.
Array provides better performance than ArrayList. If we are using a large number of ArrayList then it degrades performance because of boxing and unboxing.
Array uses static helper class Array which belongs to system namespace ArrayList implements an IList interface so, it provides a method that we can use for easy implementation.
Array belongs to namespace System ArrayList belongs to the namespace System.Collection
The Array cannot accept null. An Array can accept null.
Example:string[] array1=new string[5];array1[0]=”Hello”;array1[1]=”Bye”;
Example:ArrayList a1=new ArryList();a1.add(null);a1.insert(1,”hi”);a1.add(3);a1.add(8.23);

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Interview Questions and Answers,You Need To Know

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Can a private virtual method can be overridden?... >>
<< What are sealed classes in C#?...