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();
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

2 Comments

  1. Jon Preece July 11, 2013 Reply
    • Senthil Kumar July 11, 2013 Reply

Leave a Reply


x

Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
SQL Server 2014 Tutorial – Install SQL Server 2014 on Windows 10 machine
Problem Statement You need to install SQL Server 2014 Express edition on Windows 10 machine. Solut...