c# get index of item in list
using System;
using System.Collections.Generic;
public class Program {
public static void Main() {
List < string > myList = new List < string > () {
"Football",
"Soccer",
"Tennis",
};
// finding index
int index = myList.FindIndex(a => a.Contains("Tennis"));
// displaying index
Console.WriteLine("List Item Tennis Found at index: " + index);
}
}
4.67
6
Array.IndexOf(arrName, searchingFor)
Thank you!
6
0
5
2
int index = myList.FindIndex(a => a.Prop == oProp);
Thank you!
2
0
Are there any code examples left?
New code examples in category C#