20 August 2012

Array in C#.Net

It’s Collection of Similar Elements.
Array elements are int, Float, Char.
All elements of an array must be same type.
Arrays are Reference Type.
Arrays are implemented as Object.
They are derived from abstract Class.
Eg:
Int[] a;
Int[]a,b;
Here a, a, b are reference to an int Array.
int[] a;
a = new int [10];
Multidimensional Array:
There are two types of Multidimensional Array.
Rectangular Array.
Jagged Array.
Rectangular Array:
Every row of the array is of the same length which means we have a two dimensional array, all rows will have same number of elements.
Eg:
Int[ ,] arr = new int [ ,] {{2,4,6,8,10}{12,14,16,18,20}};
Jagged Array:
We must use different length of array elements.
Eg:
Int[ ,] arr = new int [ ,] {{2,4,6,8}{12,14,16,18}};
Difference between Jagger Array and Rectangular Array?
Jagger Array: We must use different length of array elements.
Rectangular Array: We must use same length of array elements.

No comments: