I have an IEnumerable list of objects in C#. I can use a for each to loop through and examine each object fine, however in this case all I want to do is examine the first object is there a way to do this without using a foreach loop?
I've tried mylist[0] but that didnt work.
Thanks
Remember, there may be no "first element" if the sequence is empty.
IEnumerable<int> z = new List<int>(); int y = z.FirstOrDefault();