Array and ArrayList in C#.Net

SharePoint deveopment training course

In this post we will discuss about array and arraylist in

You can check my previous posts on

Delegates in C#.Net

Advantages of WCF in 

WCF interview questions and answers.

– Arrays allow you to store a series of values that have the same data type.

– The values can be accessed by using its index number. And the index starts with 0 and the highest index is one less than the number of elements.

– Below is a string array:
string[] stringArray = new string[5];
Here new keyword is used to initialize the array.

Also you can directly put the values like below:
string[] stringArray = {“1”, “2”, “3”, “4”,”5″};

– We can access the values like below:

string value = stringArray[3];
The value will be 4;

– If you create an array, you can not resize the array.

– If you declared a interger array then only interger can be stored, if you try to initialize any other thing then it will give exception.

– Similarly you can create multidimentional array like below:

int[,] intArray = {{1, 2}, {3, 4}, {5, 6}, {7, 8},{9,10}};

– ArratList supports any type of object and always allows dynamic resizing, means the size can be increased or decreased.

– Syntax to create array:
ArrayList arr = new ArrayList();

Put the value like below:

And we can retrieve the value like below:
string value = Convert.ToString(arr[1]);

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)


About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →