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?
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.
Why don't you use list.IndexOf(object) ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With