GetValue ExamplesΒΆ

The general syntax for this method is:

arrayName.GetValue(index)

This method returns the value of the specified index.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
string[] pets = new string[]
{
   "Alyce",
   "Thisbe",
   "Francis",
   "Scratch",
   "Beatrice",
   "Shadow",
   "Beatrice"
};

Console.WriteLine(pets.GetValue(2));
Console.WriteLine(pets.GetValue(8));

Output

Francis
Unhandled Expectation: System.IndexOutOfRangeException