Say I have a foreach loop.
I have to do something with the first object of the loop that I don't have to do with any of the other objects.
How do I check if the item that's currently in the loop is the first object.
Say I have a foreach loop.
I have to do something with the first object of the loop that I don't have to do with any of the other objects.
How do I check if the item that's currently in the loop is the first object.
In my opinion this is the simplest way
foreach (var item in list)
{
if((list.IndexOf(item) == 0)
{
// first
}
// others
}