Virtual methods are needed to be overridden. You cannot override the
static methods coz they are not related to instance (only to the type).
The Microsoft considers an OOP approach when the base functionality of
handler methods should be able to override and call event by
On<Something>.
So, in your case it's not an error it's other approach, but what means
"this" in the OnEvent method? )
WBR, Alex Meleta
Blog:
http://devkids.blogspot.com
-----Original Message-----
From: BLUE [mailto:blue]
Posted At: Freitag, 27. April 2007 22:05
Posted To: microsoft.public.dotnet.languages.csharp
Conversation: Static events and OnEvent method.
Subject: Static events and OnEvent method.
I have a static class, so I've declared all variables static and also
the
event.
This is the OnEvent method:
{
if (EventName != null)
{
// Invokes the delegates
EventName(this, e);
}
}
MSDN says it should be declared in this way:
protected virtual void OnEventName(EventNameEventArgs e)
But in a static class I must declare it static: I cannot declare it
virtual:
protected static void OnEventName(EventNameEventArgs e)
It's an error or I can declare it in this way?
Thanks, Luigi.