Definition:
A delegate is a type safe “Function Pointer” which holds references to static or instance methods. Delegates are used to call methods dynamically at runtime (do not scratch your head; you will understand this by examples).
Trival Delegate Example:
A delegate is a type safe “Function Pointer” which holds references to static or instance methods. Delegates are used to call methods dynamically at runtime (do not scratch your head; you will understand this by examples).
Trival Delegate Example:
public delegate void MyDelegate(string text);
protected void Page_Load(object sender, EventArgs e)
{
MyDelegate d = new MyDelegate(MyMethod);
//d += new MyDelegate(MyMethod1);
d("hello");
}
private void MyMethod(string text)
{
Response.Write(text);
}
Reference
No comments:
Post a Comment