c# - How to require custom attribute from base class? -
i have base class derived classes put attribute on top of class this:
[myattribute("abc 123")] public class someclass : mybaseclass { public someclass() : base() { } } public class mybaseclass { public string propa { get; set; } public mybaseclass() { this.propa = //attribute value of derived } }
how enforce derived classes need attribute, use attribute value in base constructor?
maybe instead of using custom attribute use abstract class abstract property. using method ensure every non-abstract derived class implement property. simple example on msdn
Comments
Post a Comment