Cloud Training (Online)




Anonymous Delegate and Anonymous Type in C#

Below is a simple example demonstrating the usage of the Anonymous Delegate which is assigned to the Fun class.

The example demonstrates the delegate which concatenates the FirstName and last name of anonymous type and displays it

Anonymous Delegate and Anonymous Type

Func<string, string, string> FullName =

delegate(string FirstName, string LastName)

{

return FirstName + " " + LastName;

};

var Name = new { FirstName = "Senthil", LastName = "Kumar", Name = FullName };

Console.WriteLine(Name.Name);

Console.ReadLine();