Skip to content

Instantly share code, notes, and snippets.

@ledsun
Created February 29, 2012 02:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ledsun/1937208 to your computer and use it in GitHub Desktop.
Save ledsun/1937208 to your computer and use it in GitHub Desktop.
C#のラムダ式チートシート

式形式のラムダ

(n) => a == n;

ステートメント型のラムダ

(n) => { return a == n; };

何もしないラムダ

(x) => { };

引数がないラムダ

() => 0

引数に型を指定したラムダ

(int x) => x * 2

引数が1つの場合は、引数のカッコを省略可

 x => x * 2

引数が複数のラムダ

(x, y) => x * y

引数が複数の型指定したラムダ

(int x, int y) => x * y

引数の型指定をしたステートメント型ラムダ

(int x) => { return x * 2; }

こんなのもアリらしい

() => Console.WriteLine("Hello!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment