Created
February 9, 2015 04:59
-
-
Save davidfowl/0a1c231719a905f0d194 to your computer and use it in GitHub Desktop.
C# type inference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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