tags:

views:

56

answers:

3

Here's what I have:

public int FindItem(int elementoABuscar)
{
    int indice = vectorNumeros.FindIndex(0, asd);
    return indice;
}

I can't seem to figure out the second part of the FindIndex method.

How would I find the index of elementoABuscar?

+11  A: 

Just use List<int>.IndexOf:

int indice = vectorNumeros.IndexOf(elementoABuscar);

FindIndex is used to find an item which matches a particular predicate - you don't need it here, if you're just trying to find an element directly.

Note that if your list is sorted, you could also use List<T>.BinarySearch.

Jon Skeet
A: 

Why don't you use list.IndexOf(object) ?

thelost
A: 

Try

int indice = vectorNumeros.IndexOf(elementoABuscar); 

msdn reference

corn3lius
i type too slow :(
corn3lius