473,581 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6605
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******** ********@tk2msf tngp13.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(r eusability) 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****@bldhoun d.com> wrote in message
news:O%******** ********@TK2MSF TNGP10.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******** ********@tk2msf tngp13.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******** ********@TK2MSF TNGP10.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(r eusability) 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****@bldhoun d.com> wrote in message
news:O%******** ********@TK2MSF TNGP10.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******** ********@tk2msf tngp13.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****@bldhoun d.com> wrote in message
news:Op******** ******@TK2MSFTN GP15.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******** ********@TK2MSF TNGP10.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(r eusability) 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****@bldhoun d.com> wrote in message
news:O%******** ********@TK2MSF TNGP10.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******** ********@tk2msf tngp13.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****@bldhoun d.com> wrote in message
news:Op******** ******@TK2MSFTN GP15.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****** **********@TK2M SFTNGP10.phx.gb l...
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
functionalit y(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****@bldhoun d.com> wrote in message
news:O%***** ***********@TK2 MSFTNGP10.phx.g bl...

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**** ************@tk 2msftngp13.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.LabelT ext = 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******** ******@TK2MSFTN GP09.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****@bldhoun d.com> wrote in message
news:Op******** ******@TK2MSFTN GP15.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******** ********@TK2MSF TNGP10.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(r eusability) 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****@bldhoun d.com> wrote in message
news:O%******** ********@TK2MSF TNGP10.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******** ********@tk2msf tngp13.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****@bldhoun d.com> wrote in message
news:uQ******** ******@TK2MSFTN GP12.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.LabelT ext = 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******** ******@TK2MSFTN GP09.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****@bldhoun d.com> wrote in message
news:Op******** ******@TK2MSFTN GP15.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******** ********@TK2MSF TNGP10.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(r eusability) 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****@bldhoun d.com> wrote in message
news:O%******** ********@TK2MSF TNGP10.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******** ********@tk2msf tngp13.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
524
by: Chris Dunaway | last post by:
When using a PropertyGrid, I have an object with a Date property, but I am only interested in the Time portion. How do I make the PropertyGrid allow editing the time only? Just the hours and minutes, preferably? Thanks -- Chris dunawaycsbcglobal_lunchmeat_net
10
1842
by: JustSomeGuy | last post by:
I have a few classes... class a : std::list<baseclass> { int keya; }; class b : std::list<a> { int keyb;
0
1303
by: Kurt Lange | last post by:
no... the array is created dynamically. and no... that defeats the purpose of what im trying todo.. encapsulate all initializing of variables in base class... derive from it... by deriving from base class, and casting, derived classes would already have their variables initialiezed(cause they have already been initialized in the base...
0
1224
by: m. pollack | last post by:
<I've reposted this as it was slipping away over the horizon Hi all, I've been writing an application that uses a class object (call it Element) that I need to expose to the user at runtime for editing. To do this, I've been using the PropertyGrid control. The Element object has a collection property that contains references to other...
2
13737
by: Andrew | last post by:
I am trying to set the column information - which ones I want displayed and how with the web grid control. The interface has some big differences when compared to the winform. Is this possible without having the dataset match ? I think yes... but ... here's how I approached it: ( create new DataGridColumns, add properties and then add each...
1
915
by: Sanjeev | last post by:
Hi , Can anyone help on this? Thank you, Sanjeev "Sanjeev" <nospam@notvalid.com> wrote in message news:OG4VyxwnDHA.2444@TK2MSFTNGP09.phx.gbl... > Hi, >
2
1294
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the username - but also determine the UserID from what was selected (using DisplayName from the combo box?? I can populate the combo box without problems -...
4
2358
by: John Richardson | last post by:
My original posting (Dec 12, this group) is copied below, but it boils down to a simple question first: does an inherited class prevent certain internal properties (inherited from an ancestor class) from being visible to GetType().GetMethod()? And can I call GetMethod from the context of the ancestor? Basically, can I get the following to...
0
1280
by: Johnny J. | last post by:
I posted this last week, but didn't get any reply. I'm trying again now, because I'm getting desperate - I've tried everything I can think of myself. PLEASE help somebody. I've made an inherited ListView control with a customized ColumnHeader Type. I've overwritten the Columns property with a collection of my custom ColumnHeader items. Now...
0
7876
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7804
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7910
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8180
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6563
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2307
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.