KEMBAR78
Array in c# | PPTX
 Array are the homogeneous(similar) collection of data types.
 Array Size remains same once created.
 Simple Declaration format for creating an array
type [ ] identifier = new type [integral value];
 You declare an array variable by specifying:
◦ The element type of the array.
◦ The rank of the array.
◦ The name of the variable
This specifies the rank of the
array
This specifies the name of the array variable
This specifies the element type of the
array
type[ ] name;
Methods of creating and initializing arrays at compile time
Array
Single Dimensional
Array Multi-Dimensional Array
Jagged Array
 The one dimensional array or single
dimensional array in C# is the simplest type
of array that contains only one row for
storing data.
 Declaration: double[] balance = new
double[10];
int [] marks = new int[2] { 99, 98, 92, 97, 95};
int[] score = marks;
 Multi-dimensional arrays are also called
rectangular array.
 Stored sequentially.
 It contains more than one rows.
 Declaration: type[,] array = new type[9, 9];
array[3,8] = 100;
string[,] array2Db = new string[3, 2]
{ { "one", "two" }, { "three", "four" }, { "five", "six"
} };
 A jagged array is an array whose elements are
arrays.
 The elements of a jagged array can be of
different dimensions and sizes.
 Declaration:
int[][] jaggedArray = new int[3][];
int[][,] jagged = new int[3][,]
{ new int[,] { {1,3}, {5,7} },
new int[,] { {0,2}, {4,6}, {8,10} },
new int[,] { {11,22}, {99,88}, {0,9} } };
Thank You
4/30/2019 13

Array in c#

  • 2.
     Array arethe homogeneous(similar) collection of data types.  Array Size remains same once created.  Simple Declaration format for creating an array type [ ] identifier = new type [integral value];
  • 3.
     You declarean array variable by specifying: ◦ The element type of the array. ◦ The rank of the array. ◦ The name of the variable This specifies the rank of the array This specifies the name of the array variable This specifies the element type of the array type[ ] name;
  • 5.
    Methods of creatingand initializing arrays at compile time
  • 6.
  • 7.
     The onedimensional array or single dimensional array in C# is the simplest type of array that contains only one row for storing data.  Declaration: double[] balance = new double[10];
  • 8.
    int [] marks= new int[2] { 99, 98, 92, 97, 95}; int[] score = marks;
  • 9.
     Multi-dimensional arraysare also called rectangular array.  Stored sequentially.  It contains more than one rows.  Declaration: type[,] array = new type[9, 9]; array[3,8] = 100;
  • 10.
    string[,] array2Db =new string[3, 2] { { "one", "two" }, { "three", "four" }, { "five", "six" } };
  • 11.
     A jaggedarray is an array whose elements are arrays.  The elements of a jagged array can be of different dimensions and sizes.  Declaration: int[][] jaggedArray = new int[3][];
  • 12.
    int[][,] jagged =new int[3][,] { new int[,] { {1,3}, {5,7} }, new int[,] { {0,2}, {4,6}, {8,10} }, new int[,] { {11,22}, {99,88}, {0,9} } };
  • 13.