Searches for object and returns the zero-based index
using System;
using System.Collections.Generic;
public class Example
{
public static void Main()
{
List<string> myList = new List<string>();
myList.Add("A");
myList.Add("B");
myList.Add("C");
Console.WriteLine();
foreach (string d in myList)
{
Console.WriteLine(d);
}
Console.WriteLine(myList.IndexOf("A"));
Console.WriteLine(myList.IndexOf("B", 3));
Console.WriteLine(myList.IndexOf("B", 2, 2));
}
}
Related examples in the same category