Why doesn't C# infer my generic types?

后端 未结 7 1745
小鲜肉
小鲜肉 2020-11-22 16:38

I\'m having lots of Funcy fun (fun intended) with generic methods. In most cases C# type inference is smart enough to find out what generic arguments it must use on my gener

相关标签:
7条回答
  • 2020-11-22 17:15

    C# will not infer generic types based on the return type of a generic method, only the arguments to the method.

    It also doesn't use the constraints as part of the type inference, which eliminates the generic constraint from supplying the type for you.

    For details, see Eric Lippert's post on the subject.

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