A method with a single expression such as:
int Test (int x) {
return x * 2;
}
can be written as an expression-bodied method.
int Test (int x) => x * 2;
Expression-bodied functions can also have a void return type:
void Test (int x) => Console.WriteLine (x);
using System; class MainClass/* w ww . j a v a2 s.co m*/ { static void Test (int x) => Console.WriteLine (x); public static void Main(string[] args) { Test(4); } }