C# LINQ Background Topics
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Delegates - Delegate declarations
Why learn about delegates?
When learning LINQ, it is important to have a good understanding of delegates in C#. Many of the more powerful capabilities of LINQ make use of delegates.
What is a delegate?
A delegate is simply a reference to a method. Delegates can be stored and passed around in a variable, and hence they must have a type definition:
private delegate int FuncTwoInts(int one, int two);
The line above defines the type
FuncTwoInts type is a reference to a method that takes two
int parameters and returns a single
Declare a new type
SayHello as a delegate that takes a single
string parameter and returns a
// Uncomment the SayHello delegate declaration
// Following the example in the lesson, declare the
// type SayHello as a delegate that takes a single
// string parameter and returns a string result.
// public ... SayHello ...
public static class DelegatesExercise1
public static void CallSayHelloDelegate(SayHello func)
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content