C Sharp Anonymous Methods Tutorials


C Sharp Anonymous Methods Assignment Help By Online Tutoring and Guided Sessions from assignmenthippo.com

  • It is a methods with only method body
  • It has no method name
  • It supports a mechanism to transfer a code as a delegate argument
  • It does not require any return type
  • Return type is accessed from the return statement of the method body

Syntax for representing Anonymous Method

  • It requires delegate keyword
  • Need to create delegate instance


delegate void Change (int n);


Change c= delegate (int x1)


System.Console.WriteLine(“anonymously : {0}”, x1);


  • System.Console.WriteLine(“Anonymous : {0}”, x1); is the anonymous method’s body of the method
  • Anonymous method and / or named method can be used for calling a delegate
  • It is actually sending the method arguments to a delegate object

Calling Statement



The following method demonstrates the concept of using anonymous methods

anonymous methods image 1