WHAT IS THE DIFFERENCE BETWEEN ARRAY AND ARRAYLIST.

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
C# 
 487  View(s)
Ratings:
Rate this:
I want to difference between Array and Arraylist please explain it.
  1. aditya kumar Patel

    Post:254

    Points:1810
    Re: What is the difference between Array and Arraylist.

    Arrays are strongly typed collection of same datatype and these arrays are fixed length that cannot be changed during runtime. Generally in arrays we will store values with index basis that will start with zero. If we want to access values from arrays we need to pass index values.

              string[] arr = new string[2];
    

                arr[0] = "aditya";

                arr[1] = "rejeev";

     

    Array lists are not strongly type collection. It will store values of different datatypes or same datatype. Array list size will increase or decrease dynamically it can take any size of values from any data type. These Array lists will be accessible with “System.Collections” namespace

    ArrayList strarr = new ArrayList();

    strarr.Add("Shivam"); // Add string values strarr.Add(10);   // Add integer values strarr.Add(10.05); // Add float values

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!