Search for object and returns the index of the first occurrence within the entire Array in CSharp
Description
The following code shows how to search for object and returns the index of the first occurrence within the entire Array.
Example
//from w ww . ja v a 2 s . c o m
using System;
public class Example
{
public static void Main()
{
string[] myValues = { "2001",
"1999",
"2000",
"1234",
"2002",
"2001",
"4567" };
Console.WriteLine(Array.IndexOf(myValues, "2001"));
}
}
The code above generates the following result.