Search object and returns index of last occurrence within offset List in CSharp
Description
The following code shows how to search object and returns index of last occurrence within offset List.
Example
using System;// w w w . ja v a 2s .co m
using System.Collections.Generic;
public class Example
{
public static void Main()
{
List<string> myData = new List<string>();
myData.Add("A");
myData.Add("B");
myData.Add("C");
myData.Add("D");
myData.Add("A");
foreach(string myD in myData)
{
Console.WriteLine(myD);
}
Console.WriteLine(myData.LastIndexOf("A", 3));
}
}
The code above generates the following result.