R
Richard
Hi,
I'm pretty new to C# and only have 6months with vb.net. However my question
regards C# and events.
Basically I've a class which uses a number of events to inform the main
application when certain conditions are met. The events work spot-on, so
long as I've typed all the event types into my main app.
e.g. The Class has;
public delegate void Connected(bool bConnected);
public event Connected ConnectedEvent;
Within my main application i then create a variable called "boo" e.g.
clsBoo boo = new clsBoo();
I then create the event;
Boo.ConnectedEvent += new Playabout.clsBoo.Connected(oo_ConnectedEvent);
I then have to type the actual interface like so
private void boo_ConnectedEvent(bool bConnected)
{
MessageBox.Show("Are we connected? " + bConnected.ToString());
}
Having to do the above seems very lengthy and requires that you know the
design of the event e.g. what's going to be placed between the brackets. In
visual basic and vb.net, as soon as I create a variable and assign a class
to it, all the events are automatically populated within the IDE. Why doesn
't C# do this?
If I never knew the design of the event coming from say a C# dll, then how
would I be expected to know all the events within the dll?
I've also noticed that if I don't code all the events listed within the c#
class I've created, then the class will raise an error when it attempts to
call it.
Hoping that someone can clear this up for me.
Thanks
I'm pretty new to C# and only have 6months with vb.net. However my question
regards C# and events.
Basically I've a class which uses a number of events to inform the main
application when certain conditions are met. The events work spot-on, so
long as I've typed all the event types into my main app.
e.g. The Class has;
public delegate void Connected(bool bConnected);
public event Connected ConnectedEvent;
Within my main application i then create a variable called "boo" e.g.
clsBoo boo = new clsBoo();
I then create the event;
Boo.ConnectedEvent += new Playabout.clsBoo.Connected(oo_ConnectedEvent);
I then have to type the actual interface like so
private void boo_ConnectedEvent(bool bConnected)
{
MessageBox.Show("Are we connected? " + bConnected.ToString());
}
Having to do the above seems very lengthy and requires that you know the
design of the event e.g. what's going to be placed between the brackets. In
visual basic and vb.net, as soon as I create a variable and assign a class
to it, all the events are automatically populated within the IDE. Why doesn
't C# do this?
If I never knew the design of the event coming from say a C# dll, then how
would I be expected to know all the events within the dll?
I've also noticed that if I don't code all the events listed within the c#
class I've created, then the class will raise an error when it attempts to
call it.
Hoping that someone can clear this up for me.
Thanks