Delegate with return values : Delegate : Delegate C# Examples


C# Examples » Delegate » Delegate »

 

Delegate with return values









    
using  System;

delegate  int  FunctionToCall();

class  MainClass
{
      static  int  IntValue  =  5;

      public  static  int  Add2()  {
              IntValue  +=  2;
              return  IntValue;
      }

      public  static  int  Add3()  {
            IntValue  +=  3;
            return  IntValue;
      }

      static  void  Main()
      {
            FunctionToCall  functionDelegate  =  Add2;
            functionDelegate  +=  Add3;
            functionDelegate  +=  Add2;

            Console.WriteLine("Value:  {0}",  functionDelegate());
      }
}
    
   
  
   



Output

Value: 12


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Delegate
» Delegate