foreach获取索引值

            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
原文地址:https://www.cnblogs.com/wzwyc/p/6843844.html