RE: Removing inherited properties from an object.
- From: "Peter Bromberg [C# MVP]" <pbromberg@xxxxxxxxxxxxxxxxxxx>
- Date: Tue, 28 Feb 2006 05:06:31 -0800
Jeff,
Jon's comment about changing the expected usability of an object is sound.
The basic technique here, however, would be to override the settor as well as
the getter in the property:
public override string Text
{
get
{
return base.Text;
}
set
{
// your cool code here...
}
}
-- Peter
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"UJ" wrote:
I have a text object (see my previous post) that I've added some.
functionality to. But I don't want the user to be able to change the text
without calling my routines. So I added the following code:
public override string Text
{
get
{
return base.Text;
}
}
but I can still do something like testobject.text = "Fred"; and it
works. How can I make that not valid?
TIA - Jeff.
- References:
- Prev by Date: Re: Removing inherited properties from an object.
- Next by Date: Re: Removing inherited properties from an object.
- Previous by thread: Re: Removing inherited properties from an object.
- Next by thread: Re: Removing inherited properties from an object.
- Index(es):