Check out example codes for "array c#". It will help you in understanding the concepts better.
Code Example 1
string[] arrayName = { "name1", "name2", "name3" }; // Array
int[] numbers = { 1, 2, 3, 4, 5, 6, 7 }; // Array
// To execute the array
foreach (string i in arrayName)
{
Console.WriteLine(i);
} // OR
for(int i=0; i<numbers.Length; i++){
Console.WriteLine(numbers[i]);
}
Code Example 2
class TestArraysClass
{
static void Main()
{
// Declare a single-dimensional array of 5 integers.
int[] array1 = new int[5];
// Declare and set array element values.
int[] array2 = new int[] { 1, 3, 5, 7, 9 };
// Alternative syntax.
int[] array3 = { 1, 2, 3, 4, 5, 6 };
// Declare a two dimensional array.
int[,] multiDimensionalArray1 = new int[2, 3];
// Declare and set array element values.
int[,] multiDimensionalArray2 = { { 1, 2, 3 }, { 4, 5, 6 } };
// Declare a jagged array.
int[][] jaggedArray = new int[6][];
// Set the values of the first array in the jagged array structure.
jaggedArray[0] = new int[4] { 1, 2, 3, 4 };
}
}
Code Example 3
int[] Nameofarray = new int[how much is the max];
for example:
int[] X = new int[5];
Code Example 4
string[] stringArray = new string[6];
Code Example 5
int[] array = new int[]{1, 2, 3, 4, 5};
for(int i=0; i<array.Length; i++){
Console.WriteLine(array[i]);
}
Code Example 6
string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
Learn ReactJs, React Native from akashmittal.com