c# - Force attribute usage in subclass of abstract superclass -


How do I apply a subclass to apply some of my superclass properties? The reason for this is that I want to use attributes for general information about class, e.g. "Display name", "description" or "abilities"

So I thought I could implement them in super-classes and force them to implement sub-class properties.

Is there anything like the abstract attribute for the methods?

  [summary declareme] Public abstract class InheritMe {public abstract Zero disclaimer (); }   

As your class will be running sooner or later,

You can add some sample code.

  class program {static void main (string [] args) {var a = new SubA (); Var B = New Subbine (); }} Class base class {public base class () {type t = gatetype (); If (T. ISDefine (typef (serialable attribute), false) == incorrect) {console. Weedline ("bad implementation"); New Invalid Operation Throw Exception (); } Console. Wrightite ("Good implementation"); }} [Serialable] Class SubA: Base Class {} Class Subbie: Base Class {}   

Last word, do not be too careful with yourself. Once I was doing my design, I always thought that I could incorrectly call two methods or forget to do something, then I made a complex design in a complex to stop its possible mistakes. Changed. Later I threw the guard, was just throwing an exception and the code used to locate the unforeseen circumstances was surrounded by the #if DEBUG .

Comments