Callbacks / Events in C#
Iv'e pretty new to C# ATM and I seem to be having trouble with Jabber-Net
Im trying to create a basic chat application that will connect users via Jaber Services, the issues im having are with the Callbacks.
The main error I seem to get is about the "Event required but used like 'type'", or something along those lines..
Im at work atm so i cant give you full details but it seems to be when i try adding callbacks.. For example:
JabberClient Jabber = new JabberCLient();
Jabbaer.OnConnec开发者_如何学JAVAt += new jabber.connection.XmppStream.OnConnect(Some_event_function);
Now this code was just of the top of my head and may be wrong, i work by fixing errors as I'm learning but I get an error that basically telling me that what im doing should be done as an event but im using as a type
Can anybody shed some light on the matter please.
Regards Robert Pitt
In principle, the line
Jabbaer.OnConnect += new
jabber.connection.XmppStream.OnConnect(Some_event_function);
is wrong because XmppStream.OnConnect is a property and you need a delegate definition at that point. But instead of debugging what came from your memory, just use the shorthand form:
Jabbaer.OnConnect += Some_event_function;
Replace the second line with:
Jabber.OnConnect += Some_event_function;
精彩评论