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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -