int[ ] a= new int[7];
or
int[] a=new int[] {5,10,20};
or
int[] a= {1,2,3,4};
To decalre 2D Arrays
int[ , ] a;
a=new int[3,3];
How to add an array in C## ???
class DeclareArraysSample
{
public static void Main()
{
// Single-dimensional array
int[] numbers = new int[5];
// Multidimensional array
string[,] names = new string[5,4];
// Array-of-arrays (jagged array)
byte[][] scores = new byte[5][];
// Create the jagged array
for (int i = 0; i %26lt; scores.Length; i++)
{
scores[i] = new byte[i+3];
}
// Print length of each row
for (int i = 0; i %26lt; scores.Length; i++)
{
Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length);
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment