-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
  • 27,144
  • 16
  • 62
  • 82

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,797
  • 2
  • 27
  • 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,915
  • 1
  • 19
  • 37