Boz,
#3 isn't so important, because that is a private implementation, and the
naming conventions don't deal with private members (after all, they are
private, and not exposed).
You have the naming conventions right for 1 and 2. The only thing I
would say is that your event handler should follow the pattern for events
already established.
This means that you have two parameters. The first is of type object,
named sender, which is the instance of the object that fired the event.
The second is a class that derives from EventArgs (or EventArgs itself,
if there is no extra information).
In this case, you would have a class named DataAvailableEventArgs which
exposes a property named Data, which would expose your string.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
<jj********@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
I'm trying to pin down a good naming convention for the 3 things
required to implement an event.
You need:
1) a delegate
2) an event
3) an event handler
Below is my understanding of a naming convention based on the Windows
Forms events. Can someone let me know if this convention is standard,
or suitable or just plain wrong.
Cheers
Boz
delegate void DataAvailableEventHandler(string data);
class ServerClass
{
public event DataAvailableEventHandler DataAvailable;
public FireEvent()
{
if (DataAvailable != null)
{
DataAvailable("bang");
}
}
}
class ClientClass
{
public ClientClass(ServerClass server)
{
server.DataAvailable += new
DataAvailableEventHandler(ServerClass_DataAvailabl e);
}
private ServerClass_DataAvailable(string data)
{
Trace.WriteLine("I got some data:\n" + data);
}
}