Arrays in C#
Array is collection of variable of same datatype .
Syntax to declare arrays :
DataType[] arrayname ;
Arrays are following types : single dimensional , two dimensional and jagged arrays
Single-dimensional array :
- int[] singlearray1 = new int[5];
- int[] singlearray2 = new int[] { 1, 3, 5, 7, 9 };
- int[] singlearray3 = { 1, 2, 3, 4, 5, 6 };
Two dimensional array :
- int[,] twoDimensionalArray1 = new int[2, 3];
- int[,] twoDimensionalArray2 = { { 1, 2, 3 }, { 4, 5, 6 } };
Jagged array :
jaggedArray[0] = new int[4] { 1, 2, 3, 4 };
No comments:
Post a Comment