C# get index in ForEach Loop

Last modified: June 28, 2021
static void Main(string[] args) { var cities = new List<string>() {"Hong Kong", "London", "New York" }; foreach(var city in cities) { int index = cities.IndexOf(city); } }