Created
February 8, 2015 11:55
-
-
Save ufcpp/1d8fe384cdc18f3ead34 to your computer and use it in GitHub Desktop.
type inference of out parameters in lambda expressions
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
delegate bool TryParse<T>(string text, out T result); | |
class Program | |
{ | |
static void Main() | |
{ | |
TryParse<int> parse1 = (string s, out int result) => int.TryParse(s, out result); // これは OK | |
TryParse<int> parse2 = (s, out int result) => int.TryParse(s, out result); // ダメ。1個だけ型名明示とかできない。 | |
TryParse<int> parse3 = (s, out result) => int.TryParse(s, out result); // ダメ。out 型推論とかない。この機能がほしい。 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment