views:

41

answers:

1

I have a list of nullable ushorts :

List<ushort?> items = new List<ushort?>();

and I'm trying to get the following to work, but I can't - for some reason.

int GetIndex(ushort value)
{
    return ?
}

what I'm trying is :

ushort? x = value;
int idx = items.FindIndex(x);

But I'm getting :

"Best overloaded method has some invalid arguments" error

Any ideas?

+3  A: 

You should call IndexOf.

The FindIndex method is a more advanced method that takes a delegate and finds the index of the first item that matches the delegate (it calls the delegate on every item and returns the index of the first item for which the delegate returned true)

Unelss it contains other logic, your entire function can be replaced by a call to IndexOf

SLaks
dear lord, it was that simple...
Maciek