CSharp - Method Expression Body

Introduction

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);

Demo

using System;
class MainClass/*from   w w  w. j a v a 2 s . com*/
{
   static void Test (int x) => Console.WriteLine (x);
   public static void Main(string[] args)
   {
       Test(4);
   }
}

Result