c# - How to make static class description that is required for subclasses? -
edit: not asking property. if there's way make required attribute, that's fine too.
i can't abstract static
in c#, how can make static property description
of type , require in sub types?
public abstract class typea { public /*required*/ static string description {get;} } public class typeb : typea { //description not implemented, compile error }
note aware can done when it's not static, feel description of type more correct when it's static. e.g. typeb.description
clear, instance.description
misleading @ best.
this answer here suggesting check attribute in constructor best i've come across far, still i'd restriction that's compile-time.
inheritance , static members don't mix.
you cannot inherit static members. if base class , derived class happen each have member same signature, these members in no way related each other.
this means can't force subclass "implement static member". reason why interfaces don't have static members.
Comments
Post a Comment