-4

For example I want to find the third element of this list by its index

List<Tuple<int, int>> list;
Random random = new Random();
list = new List<Tuple<int, int>>();

int i;  
for (i = 0; i < 4; i++)
{
    list.Add(new Tuple<int, int>(random.Next(0, 5), random.Next(0, 5)));
    Console.WriteLine("[{0}]=[{1}]", list.Count, list.);
}

thanks for the help

jh314
  • 25,902
  • 15
  • 60
  • 80

3 Answers3

0

You can do this by using .ElementAt(i), although using the normal list[i] index accessor should also work.

Fred Kleuver
  • 7,547
  • 2
  • 24
  • 38
0

I think list[index] will do the trick.

Bastos
  • 1
  • 2
0

You can just use list1[0];

For more information use this link

Community
  • 1
  • 1
Pradnya Bolli
  • 1,872
  • 1
  • 16
  • 36