Searches for object and returns the zero-based index of the last occurrence
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("B");
myList.Add("A");
Console.WriteLine();
foreach (string d in myList)
{
Console.WriteLine(d);
}
Console.WriteLine(myList.LastIndexOf("A"));
Console.WriteLine(myList.LastIndexOf("A", 3));
Console.WriteLine(myList.LastIndexOf("A", 4, 4));
}
}
Related examples in the same category