How to access index in IEnumerable object in C#?

后端 未结 5 1553
-上瘾入骨i
-上瘾入骨i 2020-12-18 18:12

I have an IEnumerable object. I would like to access based on index for instance:

for(i=0; i<=Model.Products; i++)
{
      ???
}

Is this

5条回答
  •  再見小時候
    2020-12-18 18:50

    var myProducts = Models.Products.ToList();
    for(i=0; i< myProducts.Count ; i++)
    {
          //myProducts[i];
    }
    

提交回复
热议问题