C#ArrayArray.IndexOf

Searches for the specified object and returns the first index.

문법

Array.IndexOf(array, value)

예제

아래 값을 입력하면 예제에 즉시 반영됩니다.

string
fruits
idx
IndexOf
Console
WriteLine
string[] fruits = { "apple", "banana", "cherry" };
int idx = Array.IndexOf(fruits, "banana");
Console.WriteLine(idx);   // 1