C# 7.0 Feature : Local Functions




With the release of C# 7.0, Microsoft adds a new feature called 'Local Functions' as enhancement of C-Sharp language, which allow you to local methods to be create and called within a method

A local function is available to the method it is defined inside only. 

See the below example:

I am creating add and subtract method inside main method and also calling in main method.

static void Main(string[] args) 
{    
  int Add(int a, int b) 
  {
    return a + b; 
  } 
  int Subtract(int a, intb)
  {
      return a - b;
  }
 
  Console.WriteLine(Add(3,4)); 
  Console.WriteLine(Subtract(10,3))
  Console.ReadKey(); 
}     


C# 7.0 Feature : Local Functions C# 7.0 Feature : Local Functions Reviewed by kamal kumar das on January 03, 2017 Rating: 5

No comments:

ads 728x90 B
Powered by Blogger.