Suggested technique for 'overloading' an inherited property

J

Jack Addington

I have create a base class for a user control as well as a related base
class for its logic (nonvisual). As part of the non-visual class I have a
variable that references the base user object and a property to set it.

class VisualBase : ...Control { ... }

class LogicBase
{
private VisualBase _vObj;
public VisualBase VObj {get;set;}
}

Now I then went and inherited from both and created much more advanced
objects (VisualChild and LogicChild). I need a reference to the VisualChild
in the LogicChild but I wasn't sure the best way to code it. Do I just
rename the original or should I just change the property type. The question
then is in the other methods of the base/child logic class should I be using
the private _vObj or the public VObj property?

Should it be:

class LogicChild : LogicBase
{
public VisualChild VObj
{ get { return (VisualChild) _vObj;}
{ set { _vObj = (VisualBase)Value;}
}

or do I just add a new private variable of type VisualChild?

I've tried a few things and the compiler seems to let me get away with it so
I would appreciate any help.

thanks kindly,

jack
 
J

Jack Addington

the should be part should say:

public 'new' VisualChild VObj so it can replace the name...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top