Search for object and returns the index within the range of Array that extends from the specified index to the last element in CSharp
Description
The following code shows how to search for object and returns the index within the range of Array that extends from the specified index to the last element.
Example
using System;/* w w w . ja v a2 s . co m*/
public class SamplesArray
{
public static void Main()
{
Array myArray = Array.CreateInstance(typeof(String), 12);
myArray.SetValue("the", 0);
myArray.SetValue("quick", 1);
myArray.SetValue("brown", 2);
myArray.SetValue("fox", 3);
myArray.SetValue("jumps", 4);
myArray.SetValue("over", 5);
myArray.SetValue("the", 6);
myArray.SetValue("lazy", 7);
myArray.SetValue("dog", 8);
myArray.SetValue("in", 9);
myArray.SetValue("the", 10);
myArray.SetValue("barn", 11);
int myIndex = Array.IndexOf(myArray, "in", 4);
Console.WriteLine(myIndex);
}
}
The code above generates the following result.