Earn income with your C# skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

How to get a list item by index in C#.

Using an indexer.

We can use the indexer of the list to access the list item by its index.

var int = new List<int>() { 1, 2, 3, 4, 8, 10 };

// access list item by index

var firstInt = int[0]; 

Using the Linq ElementAt() method.

using System.Linq;

var ints = new List<int>() { 1, 2, 3, 4, 8, 10 };

var firstInt = ints.ElementAt(0);

Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0