Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying To Understand Delegates
Message
From
01/01/2008 23:14:16
Handi Rusli
PT. Alam Sumbervita
Jakarta, Indonesia
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01278832
Message ID:
01278879
Views:
21
Hi Kevin,

Did you know about object references in VFP ?
Local myText as TextBox

myText = thisform.text1
myText.Value = "Hello"
well, you have to see Delegates as Method references. When you invoke a delegate, it means that you invoke one or more method(s).

I am like you, I am a VFP Developer trying to understand through the lens of VFP.

If you don't mind, I suggest you to read C# School eBook at http://www.programmersheaven.com/download/50118/download.aspx This free ebook help me a lot how to see C# from the beginners perspective.

Just my 0.2 cents :-)


>Thanks. althought I'm still sorta fuzzy. Sorry for the confusion. I'm still looking C# throughg the lens of VFP.
>
>See my notes in line.
>
>
>
>// I understand this. It's the event declaration
>public event EventHandler MyFooBar;
>
>// I get this
>if (this.MyTextBox.Text == "FOO")
>
>      // I looked up the EventArgs class on MSDN. It states:
>      //
>      // "This class contains no event data; it is used by events that do not pass state
>      // information to an event handler when an event is raised. If the event handler
>      // requires state information, the application must derive a class from this class
>      // to hold the data."
>      //
>      // So this creates and passes a default EventArgs class because OnMyFooBar
>      // takes an EventArgs parameter, correct?
>	this.OnMyFooBar(new EventArgs());
>
>
>// Lastly, this raises the MyFooBar event:
>protected virtual void OnMyFooBar(EventArgs e)
>{
>        // This is don't get at all. MyFooBar is an event definition. How can it be Null?
>        // What would make it not null?
>	if MyFooBar != null)
>		MyFooBar(this, e);
>}
>
>
>
>This I need help with:
>
>
>
>// Can you translate this into english for me?
>this.oMyControl.MyFooBar += new System.EventHandler(this.oMyControl_MyFooBarHandler);
>
>// This is the function to run when the event is raised, correct?
>private void oMyControl_MyFooBarHandler(object sender, System.EventArgs e)
>{
>	// whatever your code needs to be
>}
>
Handi Rusli
"Treat people with respect and courtesy, and one will be blessed. Complete task heartily, with best effort and responsibility, and one can achieve the greatest."
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform