So the weird situation I came across today with OrderBy:
Func<SomeClass, int> orderByNumber =
currentClass =>
currentClass.SomeNumber;
Then:
someCollection.OrderBy(orderByNumber);
This is good, but I was going to create a method instead, because it can be used elsewhere than orderBy.
private int ReturnNumber(SomeClass currentClass)
{
return currentClass.SomeNumber;
}
Now when I try to connect it to OrderBy:
someCollection.OrderBy(ReturnNumber);
He cannot infer a type like him if I use Func. It seems to me that they should be the same, since the method itself is "strongly typed", like Func.
Side Note: I understand that I can do this:
Func<SomeClass, int> orderByNumber = ReturnNumber;
source
share