how to implement a const field which in subClasses must be overwrite, i’m using .net 4, C#
because i have many classes they all have a const field(with different value) called ‘pName’.
so i want use a interface or abstract class or somthing as a parent and force these classes to override it.
it’s CONST field
You cannot
overrideaconst; nor can you declare it asstaticandoverrideit there. What you can do is re-declare it, but that is not robust – in that which version gets used depends on which you ask for (entirely at compile-time – completely unrelated to polymorphism):I would suggest you use a
virtualorabstractproperty:and
override: