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

 

posted @ 2017-05-12 08:44  wzwyc  阅读(17969)  评论(0)    收藏  举报