How to loop through a collection that supports IEnumerable?

后端 未结 5 1439
不知归路
不知归路 2020-12-23 20:00

How to loop through a collection that supports IEnumerable?

5条回答
  •  粉色の甜心
    2020-12-23 20:39

    or even a very classic old fashion method

    IEnumerable collection = new List() { "a", "b", "c" };
    
    for(int i = 0; i < collection.Count(); i++) 
    {
        string str1 = collection.ElementAt(i);
        // do your stuff   
    }
    

    maybe you would like this method also :-)

提交回复
热议问题