I have an IEnumerable object. I would like to access based on index for instance:
for(i=0; i<=Model.Products; i++)
{
???
}
Is this
The best way to retrieve an item by index is to reference your enumerable collection with an array using Linq in this way:
using System.Linq;
...
class Model {
IEnumerable Products;
}
...
// Somewhere else in your solution,
// assume model is an instance of the Model class
// and that Products references a concrete generic collection
// of Product such as, for example, a List.
...
var item = model.Products.ToArray()[index];