using System; using System.Data; using System.Configuration; 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 _Default : System.Web.UI.Page { // Define a delegate type delegate string myDelegateType(string strMsg); protected void cmdGo_Click(object sender, EventArgs e) { string strMyMessage = "Say Howdy!"; // Declare an anonymous delegate myDelegateType myDelegate = delegate(string strMsg) { string strFuncName = System.Reflection.MethodBase.GetCurrentMethod().Name; return "My function name is this: " + strFuncName + " and you told me to do this: " + strMsg; }; // Fire the delegate lblResults.Text = myDelegate.Invoke(strMyMessage); } }