what are delegates and how to use them csharp
Code Example - what are delegates and how to use them csharp
delegate result-type identifier ([parameters])
how to create a delegate in csharp
//the delegate can point to a void function and takes a string parameter
delegate void Del(string str);
public void hello(string Name)
{
Console.WriteLine("hello " + Name) ;
}
public static void main()
{
//you need to declare the delegate type above and give it a function
//that matches the delegate's funcion
Del HelloDelegate = new Del(hello);
HelloDelegate("IC");
}
/// (output) -> "hello IC"
delegates in csharp
[modifier] delegate [return_type] [delegate_name] ([parameter_list]);