[Gtk-sharp-list] Attaching method to events without explicit EventHandler instanciation
Charles-Henri d'Adhémar
cdadhemar at gmail.com
Thu Feb 21 12:39:50 EST 2008
Hello All !
I am new to mono and GTK# (I am a C++ developer) and I need to
understand something about events handler.
I hope I am in the right place to ask such a question ... If not sorry
for inconvenience !
The way a method is attached to an event seems equivalent in class
Test1 and Test2 below :
class Test1
{
static void Main()
{
...
...
button1.Clicker += new EventHandler(hello_event);
}
public static void hello_event( object o, EventArgs e)
{
Console.WriteLine("Button press");
}
}
class Test2
{
static void Main()
{
...
...
button1.Clicker += hello_event;
}
public static void hello_event( object o, EventArgs e)
{
Console.WriteLine("Button press");
}
}
Can a method (in our case hello_event) be attached to a GTK# event
without instantiating a delegate (new EventHandler(hello_event); ) ?
I have a lots of example on mono's web site and on the web where
methods are attached without invoking the "new EventHandler" syntax,
but I haven't seen any specification or documentation which explicitly
say so (and I have looked for ;-) ).
Any body can help me understanding this ?
Thank you very much in advance !
Cheers,
Chicha
More information about the Gtk-sharp-list
mailing list