C# method group type inference

后端 未结 1 652
我在风中等你
我在风中等你 2021-01-31 21:17

I\'m trying to write a generic method that supplies parameters and calls a function, like this:

class MyClass {
    public int Method(float arg) => 0;
}

TRes         


        
1条回答
  •  执笔经年
    2021-01-31 22:02

    Unfortunately no, that's a limitation of type inference in C#. It doesn't really do much with return types, which is what's needed in your case to fully infer the generic arguments to Call<>.

    0 讨论(0)
提交回复
热议问题