Basic of Array   Leave a comment

Arrays are data structure used to store collection of values.
Declaration: Datatype[] variable = new Datatype[length];
All elements should be of same data types.
We can assign value to array elements by using [] square brackets and index inside it and then assignment operator.
f. ex: arr[1] = 0;
You can also assign the value in advance using curly braces notation.
f. ex: int[] y = new int[] {1,2,3};              
          int[] y = {1,2,3};
There are also two types of multi dimention array in C# retangular and jagged array.
In declaration it contains comma for seperation of dimention and jagged array is array of arrays.
Rectangular: int[,] a = new int[1,1];
Jagged: int[][] = new int[2][];

Advertisements

Posted November 28, 2014 by Izharuddin Shaikh in C#

Tagged with

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: