Getting a list item by index

user1909486 picture user1909486 · Mar 17, 2013 · Viewed 824.2k times · Source

I've recently started using c# moving over from Java. I can't seem to find how to get a list item by index. In java to get the first item of the list it would be:

list1.get(0);

What is the equivalent in c#?

Answer

Mitch Wheat picture Mitch Wheat · Mar 17, 2013
list1[0];

Assuming list's type has an indexer defined.