Local Method Variable Capture - CSharp Custom Type

CSharp examples for Custom Type:Local Method

Description

Local Method Variable Capture

Demo Code

using System;//from www. jav a2  s .  c  o  m
using System.ComponentModel;
class LocalMethodVariableCapture1
{
   static void Main()
   {
      int i = 0;
      AddToI(5);
      AddToI(10);
      Console.WriteLine(i);
      void AddToI(int amount) => i += amount;
   }
}

Result


Related Tutorials