Func<>の定義をLambda表現(もしくはdelegate(){} )のステートメントの前にしないとコンパイルエラーになります。 private void ButtonAnonyMethodInfo_Click(object sender, EventArgs e) { Func<int, int,int> f = null; f = (i,j ) => { return ( i < 5 ) ? i + j : f(i-1,j ) ; }; MessageBox.Show(f(20, 3).ToString()); }
Hatena タグ: 匿名関数
