-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: SeeSharp
Message 2 in Discussion
Hi, I am not sure that I understand what is special about the "delegate of a method"
part... Delegates are akin to function pointers in C/C++. They allow you to access a
particular function call without knowing at compile time which exact function will be
called. Also, a delegate defines a reference type that can be used to encapsulate a
method with a specific signature ( including the parameters passed to it, ofcourse)
For eg:- <<code fragment>> delegate void TestDelegate(string str); ................
public static void Main()
{
ADelegate(new TestDelegate(DelegatedFunction));
} public static void ADelegate(TestDelegate SomeArbitFunction)
{
SomeArbitFunction("MyString");
}
public static void DelegatedFunction(string str)
{
System.Console.WriteLine(str);
}
.........
Here , the function ADelegate, at compile time does not konw which function will be
called.( In this case, the function "DelegatedFunction" is called but it could just as
well be any other function so long as it sticks to the signature
void function(string str)
HTH,
Diwakar
PS: In fact, this is why events are handled usually with delegates, because, at
compile time, the event handler ( function that will be invoked ) is not known.
-D
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]