Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Created February 9, 2015 04:59
Show Gist options
  • Save davidfowl/0a1c231719a905f0d194 to your computer and use it in GitHub Desktop.
Save davidfowl/0a1c231719a905f0d194 to your computer and use it in GitHub Desktop.
C# type inference
public static class MyClass
{
public static void DoSomething<T>(Func<int, T, int> call)
{
}
public static void Example()
{
// This fails
DoSomething(PleaseInferInt);
// This works
DoSomething<int>(PleaseInferInt);
}
private static int PleaseInferInt(int arg1, int arg2)
{
throw new NotImplementedException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment