なぜこの C# は型チェックをしないのですか? string -> string
この例では、タイプのメソッドをとして渡そうとしていFunc<string, string>
ます。適切に型指定された関数の名前だけを渡すときに、ラムダ構文を省略できることは完全に理にかなっているように思えます。
using System;
using System.Linq;
class WeakInference
{
public static void Main (string [] args)
{
// doesn't typecheck
var hellos = args.Select (AppendHello);
// have to do this:
// var hellos = args.Select (s => AppendHello (s));
}
static string AppendHello (string s)
{
return s + "hello";
}
}