using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class namedDelegate : System.Web.UI.Page { // Define a delegate type delegate string myDelegateType(string strMsg); // This is the function that will be invoked through the delegate static string DoSomething(string strMsg) { string strFuncName = System.Reflection.MethodBase.GetCurrentMethod().Name; return "My function name is this: " + strFuncName + " and you told me to do this: " + strMsg; } protected void cmdGo_Click(object sender, EventArgs e) { myDelegateType myDelegate = new myDelegateType(DoSomething); this.lblResults.Text = myDelegate.Invoke("Say Hello!"); } }