Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created February 8, 2015 11:55
Show Gist options
  • Save ufcpp/1d8fe384cdc18f3ead34 to your computer and use it in GitHub Desktop.
Save ufcpp/1d8fe384cdc18f3ead34 to your computer and use it in GitHub Desktop.
type inference of out parameters in lambda expressions
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