List<string> items = new List<string> { "111", "222", "333" }; foreach (string item in items) { int index = items.IndexOf(item); Console.WriteLine(index); }
以下代码的执行结果是:
0 1 2