Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying To Understand Delegates
Message
 
À
01/01/2008 16:44:43
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01278832
Message ID:
01278842
Vues:
23
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
}
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform