468,556 Members | 2,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,556 developers. It's quick & easy.

REPOST:Hiding base class property from derived class instance

Base class:
class AssetBase
{
string _clli;

public string CLLI
{
get
{
return _clli;
}
set
{
_clli = value
}
}
}
In Derived Class I want to give different name to the base class property
and internally refer the base class property like below
class Asset: BaseAsset
{
public string Location
{
get
{
base.CLLI;
}
set
{
base.CLLI = value;
}
}
}

Now , when the developer use this dll in their project and create Asset
instance I want to hide the AssetBase Property CLLI , all i want to see them
is Location. I can do this by making base class properties to protected ,
but I want some of the property to be exposed to the developer
as it's defined in base class. How can I do that ?
Thanks
baski
Nov 16 '05 #1
7 6347
Please give a brief example that illustrates what you really want to do. In
the example you give, there is no reason to hide the base property with
another, since it is exactly the same as the derived one, and also nothing
the developer could possibly want to use in the base that is not exposed by
the derived property.

If you can give us an understanding of what you really want to do, we very
likely can suggest a solution for your problem.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eI****************@tk2msftngp13.phx.gbl...
Base class:
class AssetBase
{
string _clli;

public string CLLI
{
get
{
return _clli;
}
set
{
_clli = value
}
}
}
In Derived Class I want to give different name to the base class property
and internally refer the base class property like below
class Asset: BaseAsset
{
public string Location
{
get
{
base.CLLI;
}
set
{
base.CLLI = value;
}
}
}

Now , when the developer use this dll in their project and create Asset
instance I want to hide the AssetBase Property CLLI , all i want to see
them
is Location. I can do this by making base class properties to protected ,
but I want some of the property to be exposed to the developer
as it's defined in base class. How can I do that ?
Thanks
baski

Nov 16 '05 #2
Rachel,

I have base framework , which will be used for multiple clients , each
client will call the properties in different names. Base class will not be
used by the developer any where. We are using the inheritance to get most
functionality(reusability) from base class and easily adopt the new client
with simple name customization.

If the base class properties is not renamed in the derived class , I want
the developer to see as it's defined in base class from derived class
instance variable.

If you need more explanation, plese feel free to email me.

Thanks
Baski

"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
Please give a brief example that illustrates what you really want to do.
In the example you give, there is no reason to hide the base property with
another, since it is exactly the same as the derived one, and also nothing
the developer could possibly want to use in the base that is not exposed
by the derived property.

If you can give us an understanding of what you really want to do, we very
likely can suggest a solution for your problem.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eI****************@tk2msftngp13.phx.gbl...
Base class:
class AssetBase
{
string _clli;

public string CLLI
{
get
{
return _clli;
}
set
{
_clli = value
}
}
}
In Derived Class I want to give different name to the base class property
and internally refer the base class property like below
class Asset: BaseAsset
{
public string Location
{
get
{
base.CLLI;
}
set
{
base.CLLI = value;
}
}
}

Now , when the developer use this dll in their project and create Asset
instance I want to hide the AssetBase Property CLLI , all i want to see
them
is Location. I can do this by making base class properties to protected ,
but I want some of the property to be exposed to the developer
as it's defined in base class. How can I do that ?
Thanks
baski


Nov 16 '05 #3
Ah, now I understand.

When you rename the properties, do you need the originals to be unusable by
the user/developer, or do you just want them not to show up in the
"properties" window of the designer?

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Rachel,

I have base framework , which will be used for multiple clients , each
client will call the properties in different names. Base class will not be
used by the developer any where. We are using the inheritance to get most
functionality(reusability) from base class and easily adopt the new client
with simple name customization.

If the base class properties is not renamed in the derived class , I want
the developer to see as it's defined in base class from derived class
instance variable.

If you need more explanation, plese feel free to email me.

Thanks
Baski

"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
Please give a brief example that illustrates what you really want to do.
In the example you give, there is no reason to hide the base property
with another, since it is exactly the same as the derived one, and also
nothing the developer could possibly want to use in the base that is not
exposed by the derived property.

If you can give us an understanding of what you really want to do, we
very likely can suggest a solution for your problem.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eI****************@tk2msftngp13.phx.gbl...
Base class:
class AssetBase
{
string _clli;

public string CLLI
{
get
{
return _clli;
}
set
{
_clli = value
}
}
}
In Derived Class I want to give different name to the base class
property
and internally refer the base class property like below
class Asset: BaseAsset
{
public string Location
{
get
{
base.CLLI;
}
set
{
base.CLLI = value;
}
}
}

Now , when the developer use this dll in their project and create Asset
instance I want to hide the AssetBase Property CLLI , all i want to see
them
is Location. I can do this by making base class properties to protected
,
but I want some of the property to be exposed to the developer
as it's defined in base class. How can I do that ?
Thanks
baski



Nov 16 '05 #4
If any properties is renamed in derived class I want to mask that
propoerty from developer derived class instance(just like Explicit interface
implementation hide).
"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:Op**************@TK2MSFTNGP15.phx.gbl...
Ah, now I understand.

When you rename the properties, do you need the originals to be unusable
by the user/developer, or do you just want them not to show up in the
"properties" window of the designer?

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Rachel,

I have base framework , which will be used for multiple clients , each
client will call the properties in different names. Base class will not
be
used by the developer any where. We are using the inheritance to get most
functionality(reusability) from base class and easily adopt the new
client
with simple name customization.

If the base class properties is not renamed in the derived class , I want
the developer to see as it's defined in base class from derived class
instance variable.

If you need more explanation, plese feel free to email me.

Thanks
Baski

"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
Please give a brief example that illustrates what you really want to do.
In the example you give, there is no reason to hide the base property
with another, since it is exactly the same as the derived one, and also
nothing the developer could possibly want to use in the base that is not
exposed by the derived property.

If you can give us an understanding of what you really want to do, we
very likely can suggest a solution for your problem.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eI****************@tk2msftngp13.phx.gbl...
Base class:
class AssetBase
{
string _clli;

public string CLLI
{
get
{
return _clli;
}
set
{
_clli = value
}
}
}
In Derived Class I want to give different name to the base class
property
and internally refer the base class property like below
class Asset: BaseAsset
{
public string Location
{
get
{
base.CLLI;
}
set
{
base.CLLI = value;
}
}
}

Now , when the developer use this dll in their project and create Asset
instance I want to hide the AssetBase Property CLLI , all i want to see
them
is Location. I can do this by making base class properties to protected
,
but I want some of the property to be exposed to the developer
as it's defined in base class. How can I do that ?
Thanks
baski



Nov 16 '05 #5
It sounds like you want to use an interface instead of inheritance.

If you have public properties in a base class, you won't be able to mask
them in inherited classes. The reason for this is simple.

We'll say that you have object X, we'll call it a ListBox, but you need
to use it with object Y, which only takes WebControls. If X hid members
of the WebControls class, it would no longer be considered a WebControl,
and wouldn't work with object Y.

An interface of common properties will be easier for you to control.
Let those properties be the external items that the dev's work with, but
keep everything else internal.

Essentially, you can't rename properties in child classes, because then
those classes would no longer be children.

Baski wrote:
If any properties is renamed in derived class I want to mask that
propoerty from developer derived class instance(just like Explicit interface
implementation hide).
"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:Op**************@TK2MSFTNGP15.phx.gbl...
Ah, now I understand.

When you rename the properties, do you need the originals to be unusable
by the user/developer, or do you just want them not to show up in the
"properties" window of the designer?

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl.. .
Rachel,

I have base framework , which will be used for multiple clients , each
client will call the properties in different names. Base class will not
be
used by the developer any where. We are using the inheritance to get most
functionality(reusability) from base class and easily adopt the new
client
with simple name customization.

If the base class properties is not renamed in the derived class , I want
the developer to see as it's defined in base class from derived class
instance variable.

If you need more explanation, plese feel free to email me.

Thanks
Baski

"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl. ..

Please give a brief example that illustrates what you really want to do.
In the example you give, there is no reason to hide the base property
with another, since it is exactly the same as the derived one, and also
nothing the developer could possibly want to use in the base that is not
exposed by the derived property.

If you can give us an understanding of what you really want to do, we
very likely can suggest a solution for your problem.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eI****************@tk2msftngp13.phx.gbl.. .

>Base class:
>
>
>class AssetBase
>{
> string _clli;
>
> public string CLLI
> {
> get
> {
> return _clli;
> }
> set
> {
> _clli = value
> }
> }
>
>
>}
>
>
>In Derived Class I want to give different name to the base class
>property
>and internally refer the base class property like below
>
>
>class Asset: BaseAsset
>{
> public string Location
> {
> get
> {
> base.CLLI;
> }
> set
> {
> base.CLLI = value;
> }
> }
>}
>
>
>
>Now , when the developer use this dll in their project and create Asset
>instance I want to hide the AssetBase Property CLLI , all i want to see
>them
>is Location. I can do this by making base class properties to protected
>,
>but I want some of the property to be exposed to the developer
>as it's defined in base class. How can I do that ?
>
>
>Thanks
>baski
>


Nov 16 '05 #6
Well, then I don't think you can get that for free. I think you will have to
give it a protected modifier in the base class, and add a public property of
the same name in the derived class, if you want that property available.
Something like this:

// Base class protected property
protected string LabelText
{
get { return label.Text; }
set { label.Text = value;}
}

// Derived class hides it with a public property
public new string LabelText
{
get{return base.LabelText;}
set{base.LabelText = value;}
}

So you copy/paste the 2nd property into each derived class that doesn't
actually have a rename.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eD**************@TK2MSFTNGP09.phx.gbl...
If any properties is renamed in derived class I want to mask that
propoerty from developer derived class instance(just like Explicit
interface implementation hide).
"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:Op**************@TK2MSFTNGP15.phx.gbl...
Ah, now I understand.

When you rename the properties, do you need the originals to be unusable
by the user/developer, or do you just want them not to show up in the
"properties" window of the designer?

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Rachel,

I have base framework , which will be used for multiple clients , each
client will call the properties in different names. Base class will not
be
used by the developer any where. We are using the inheritance to get
most
functionality(reusability) from base class and easily adopt the new
client
with simple name customization.

If the base class properties is not renamed in the derived class , I
want
the developer to see as it's defined in base class from derived class
instance variable.

If you need more explanation, plese feel free to email me.

Thanks
Baski

"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
Please give a brief example that illustrates what you really want to
do. In the example you give, there is no reason to hide the base
property with another, since it is exactly the same as the derived one,
and also nothing the developer could possibly want to use in the base
that is not exposed by the derived property.

If you can give us an understanding of what you really want to do, we
very likely can suggest a solution for your problem.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eI****************@tk2msftngp13.phx.gbl...
> Base class:
>
>
> class AssetBase
> {
> string _clli;
>
> public string CLLI
> {
> get
> {
> return _clli;
> }
> set
> {
> _clli = value
> }
> }
>
>
> }
>
>
> In Derived Class I want to give different name to the base class
> property
> and internally refer the base class property like below
>
>
> class Asset: BaseAsset
> {
> public string Location
> {
> get
> {
> base.CLLI;
> }
> set
> {
> base.CLLI = value;
> }
> }
> }
>
>
>
> Now , when the developer use this dll in their project and create
> Asset
> instance I want to hide the AssetBase Property CLLI , all i want to
> see them
> is Location. I can do this by making base class properties to
> protected ,
> but I want some of the property to be exposed to the developer
> as it's defined in base class. How can I do that ?
>
>
> Thanks
> baski
>



Nov 16 '05 #7
Oh, I just tried the opposite, and it did compile....

What I mean is having a public property in the base class, and then hiding
it ...
------------------
protected new string CCLI...
------------------------

I haven't tried to actually use something like that, though. I'd be leery of
taking away from the public signature of a base class in a derived class,
although I can see where it might make sense if the base class is
abstract... As long as it's clear that the base class's public property
isn't really part of the type's interface (ahh... ?!?)

-Rachel
"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:uQ**************@TK2MSFTNGP12.phx.gbl...
Well, then I don't think you can get that for free. I think you will have
to give it a protected modifier in the base class, and add a public
property of the same name in the derived class, if you want that property
available. Something like this:

// Base class protected property
protected string LabelText
{
get { return label.Text; }
set { label.Text = value;}
}

// Derived class hides it with a public property
public new string LabelText
{
get{return base.LabelText;}
set{base.LabelText = value;}
}

So you copy/paste the 2nd property into each derived class that doesn't
actually have a rename.

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:eD**************@TK2MSFTNGP09.phx.gbl...
If any properties is renamed in derived class I want to mask that
propoerty from developer derived class instance(just like Explicit
interface implementation hide).
"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:Op**************@TK2MSFTNGP15.phx.gbl...
Ah, now I understand.

When you rename the properties, do you need the originals to be unusable
by the user/developer, or do you just want them not to show up in the
"properties" window of the designer?

-Rachel

"Baski" <ba***@aldensys.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Rachel,

I have base framework , which will be used for multiple clients , each
client will call the properties in different names. Base class will not
be
used by the developer any where. We are using the inheritance to get
most
functionality(reusability) from base class and easily adopt the new
client
with simple name customization.

If the base class properties is not renamed in the derived class , I
want
the developer to see as it's defined in base class from derived class
instance variable.

If you need more explanation, plese feel free to email me.

Thanks
Baski

"Rachel Suddeth" <ra****@bldhound.com> wrote in message
news:O%****************@TK2MSFTNGP10.phx.gbl...
> Please give a brief example that illustrates what you really want to
> do. In the example you give, there is no reason to hide the base
> property with another, since it is exactly the same as the derived
> one, and also nothing the developer could possibly want to use in the
> base that is not exposed by the derived property.
>
> If you can give us an understanding of what you really want to do, we
> very likely can suggest a solution for your problem.
>
> -Rachel
>
> "Baski" <ba***@aldensys.com> wrote in message
> news:eI****************@tk2msftngp13.phx.gbl...
>> Base class:
>>
>>
>> class AssetBase
>> {
>> string _clli;
>>
>> public string CLLI
>> {
>> get
>> {
>> return _clli;
>> }
>> set
>> {
>> _clli = value
>> }
>> }
>>
>>
>> }
>>
>>
>> In Derived Class I want to give different name to the base class
>> property
>> and internally refer the base class property like below
>>
>>
>> class Asset: BaseAsset
>> {
>> public string Location
>> {
>> get
>> {
>> base.CLLI;
>> }
>> set
>> {
>> base.CLLI = value;
>> }
>> }
>> }
>>
>>
>>
>> Now , when the developer use this dll in their project and create
>> Asset
>> instance I want to hide the AssetBase Property CLLI , all i want to
>> see them
>> is Location. I can do this by making base class properties to
>> protected ,
>> but I want some of the property to be exposed to the developer
>> as it's defined in base class. How can I do that ?
>>
>>
>> Thanks
>> baski
>>
>
>



Nov 16 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by JustSomeGuy | last post: by
reply views Thread by Kurt Lange | last post: by
reply views Thread by m. pollack | last post: by
1 post views Thread by Sanjeev | last post: by
4 posts views Thread by John Richardson | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.