find index of an int in a list

Viewed 154985

Is there a way to get the index of an int from a list? Looking for something like list1.FindIndex(5) where I want to find the position of 5 in the list.

5 Answers

It's even easier if you consider that the Generic List in C# is indexed from 0 like an array. This means you can just use something like:

int index = 0; int i = accounts[index];

Related