|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Inheriting and Extending internal classpublic abstract class _JobBase { private int _JobId; private int _JobName; public virtual int JobId { get{return this._JobId;} set{this._JobId = value;} } public virtual string JobName { get{return this._JobName;} set{this._JobName = value;} } public class PropertyNames{ public const string JobId = "JobId"; public const string JobName= "JobName"; } } When inheriting from _Job if I want to extend the PropertyNames inner class I am doing the following public class Job:_JobBase { public string JobNameExtended { get{return this.JobId.ToString() & " - " & this.JobName;} } public new class PropertyNames:_JobBase.PropertyNames { public const string JobNameExtended = "JobNameExtended"; } } What I want to know is if this is the correct way of extending an inner class as this works, or if there is a better way. Paul That works just fine.
Using a class as a container for a static list of names seems a bit dodgy - with all members static (const is static), there's no point in ever creating an instance of this class, in which case there's also no point in deriving from the class. Of course, if there's more to the PropertyNames class than you're showing then the use of inheritance (or even of a class) might be justified. -cd "Paul Say" <say***@tpg.com.au> wrote in message news:enXEI4QhGHA.3376@TK2MSFTNGP03.phx.gbl... This is the situation I have a base class _Job that has an internal class PropertyNames (see code )public abstract class _JobBase { private int _JobId; private int _JobName; public virtual int JobId { get{return this._JobId;} set{this._JobId = value;} } public virtual string JobName { get{return this._JobName;} set{this._JobName = value;} } public class PropertyNames{ public const string JobId = "JobId"; public const string JobName= "JobName"; } } When inheriting from _Job if I want to extend the PropertyNames inner class I am doing the following public class Job:_JobBase { public string JobNameExtended { get{return this.JobId.ToString() & " - " & this.JobName;} } public new class PropertyNames:_JobBase.PropertyNames { public const string JobNameExtended = "JobNameExtended"; } } What I want to know is if this is the correct way of extending an inner class as this works, or if there is a better way. Paul |
|||||||||||||||||||||||