topical media & game development
mashup-amazon-13-13-01-Delegates-namedDelegate.aspx.cs / cs
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!");
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.