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
foreach获取索引值
原文:http://www.cnblogs.com/wzwyc/p/6843844.html