|
using
System;
//Delegate declaration
public
delegate void
SampleDelegate(string
Text);
class
DelegatesDemo
{
public
static void Display(string Text)
{
Console.WriteLine("The string you entered is : "
+ Text);
}
public
static void Main()
{
//Instantiate the delegate and pass the reference of the
//Display() method.
SampleDelegate S = new
SampleDelegate(Display);
Console.WriteLine("Enter your text to display");
string Text = Console.ReadLine();
//Invoke the delegate, which inturn will invoke the Display() method
S(Text);
}
}
|