Hi Johann,
I am kind of confused on what you want to accomplish. Do you want to
override the event or do you simply want the derived class to be
informed when the base class raises the event?
Sorry for confusing you.
My idea is to have a abstrac "generic message class" which at the momen
looks like :
public abstract class GenericMessage: MarshalByRefObject
{
public abstract void MsgRepeated();
public abstract void MsgSent();
public abstract void MsgTransmissionError();
public virtual event EventHandler OnMsgSent;
public virtual event EventHandler OnRepeat;
public virtual event EventHandler OnTransmissionError;
}
Then I want to drive some specific message classes from this class like for
example:
public class UdpTelegram1 : GenericMessage
{
.....
}
public class UdpTelegram2 : GenericMessage
{
.....
}
..... and so on
These casses shell represent udp messages (streams), holding information in
a format used in our company.
To all this there will be a "communictaion" class, to process the messages
to be sent and received, whithout knowing the specific type of a message
(polymorphism).
If a message was sent, it would just call the GenericMessage.MsgSent() in
order to inform the sender about the success.
In order that this can work, the derived messag classes need to implement
the correspoinding methods for the notification like for example:
public override void MsgSent()
{
if(OnMsgSent != null)
{
GbMessageEventArgs e = new GbMessageEventArgs(this);
e.InfoString = "Message was successfully sent!";
OnMsgSent(this,e);
}
}
I hope I was able to explain my intentions without confusing you more.
The problem seems to be, that the compiler won't let me use the events
declared in the base class in the derived classes?
Is it forbidden in C# to inherrit events?
Rainer