2

Why can't type arguments be inferred in this simple case?

public class Test
{
  public Test()
  {
    Handle(Meh); // The type arguments for method cannot be inferred from the usage
  }

  public string Meh(int value)
  {
    return "";
  }

  public void Handle<T, U>(Func<T, U> handler)
  {
  }
}
Andreas Zita
  • 7,232
  • 6
  • 54
  • 115
  • Interestingly, If I remove the `U` type parameter, it can infer the types successfully. – Sweeper May 02 '17 at 12:27
  • Note: There is an [open issue about this](https://github.com/dotnet/csharplang/issues/129) on the C# language repository on GitHub, tagged as a feature request, so people are definitely looking at this, and the situation might change in the future. – poke May 02 '17 at 12:28

0 Answers0