Static Members derived from Interface Class
-
I have a program that consists of a number of messages type. I am trying to ensure that all messages of a given type have a dedicated handler. Each message type has its own message handler. I have created an interface base class which states all messages need a handler. Each derived class should have a single event handler, therefore I used the static keyword so that it is common across all the derived classes i.e. a single handleMsg for all instances of the msg1 class. So I implemented this: interface baseMsg { void handleMsg (); } class msg1 : baseMsg { … public static void handleMsg () { Console.WriteLine ("msg1 Handled"); } } class msg2 : baseMsg { … public static void handleMsg () { Console.WriteLine ("msg2 Handled"); } } I am getting an error CS0536: Error Message 'class' does not implement interface member 'interface member'. 'class member' is static, not public, or has the wrong return type So I cannot implement it in the way I originally thought. Does anyone have any suggestion on how I can achieve this? Thanks, LiamD
-
I have a program that consists of a number of messages type. I am trying to ensure that all messages of a given type have a dedicated handler. Each message type has its own message handler. I have created an interface base class which states all messages need a handler. Each derived class should have a single event handler, therefore I used the static keyword so that it is common across all the derived classes i.e. a single handleMsg for all instances of the msg1 class. So I implemented this: interface baseMsg { void handleMsg (); } class msg1 : baseMsg { … public static void handleMsg () { Console.WriteLine ("msg1 Handled"); } } class msg2 : baseMsg { … public static void handleMsg () { Console.WriteLine ("msg2 Handled"); } } I am getting an error CS0536: Error Message 'class' does not implement interface member 'interface member'. 'class member' is static, not public, or has the wrong return type So I cannot implement it in the way I originally thought. Does anyone have any suggestion on how I can achieve this? Thanks, LiamD
A singleton pattern for the event-handler class?
Formula 1 - Short for "F1 Racing" - named after the standard "help" key in Windows, it's a sport where participants desperately search through software help files trying to find actual documentation. It's tedious and somewhat cruel, most matches ending in a draw as no participant is able to find anything helpful. - Shog9 Ed