By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,772 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,772 IT Pros & Developers. It's quick & easy.

Event naming conventions

P: n/a
Hi all

This has baffled me for a bit now, what is a recommended naming convention
for events, my thought was the events should just be named as in the .Net
framework, ie Click.

However, some people feel preceding the name with "On" is necessary, is that
right?

Any thoughts on this?
Thanks
Kev
May 12 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,

The guideliness are to name it without On. The On prefix is added to
protected virtual method that launches the event, for example:
public event EventHandler SomeEvent;

protected virtual void OnSomeEvent(EventArgs e)
{
if (SomeEvent != null)
SomeEvent(this, e);
}

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Mantorok" <ma******@mantorok.com> wrote in message
news:e4**********@newsfeed.th.ifl.net...
Hi all

This has baffled me for a bit now, what is a recommended naming convention
for events, my thought was the events should just be named as in the .Net
framework, ie Click.

However, some people feel preceding the name with "On" is necessary, is
that right?

Any thoughts on this?
Thanks
Kev

May 12 '06 #2

P: n/a
Thanks, that's confirmed my thoughts too.

Kev

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
Hi,

The guideliness are to name it without On. The On prefix is added to
protected virtual method that launches the event, for example:
public event EventHandler SomeEvent;

protected virtual void OnSomeEvent(EventArgs e)
{
if (SomeEvent != null)
SomeEvent(this, e);
}

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Mantorok" <ma******@mantorok.com> wrote in message
news:e4**********@newsfeed.th.ifl.net...
Hi all

This has baffled me for a bit now, what is a recommended naming
convention for events, my thought was the events should just be named as
in the .Net framework, ie Click.

However, some people feel preceding the name with "On" is necessary, is
that right?

Any thoughts on this?
Thanks
Kev


May 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.