J
Jeroen Smits
To Microsoft or other people who are interested, I have a feature request:
I would really like to have an option to 'hide' a property or method from an
inherited class. For example when I create a subclass and supply a default
value for a property. Currently I create a new property, using the new
keyword, and only supply the get accessor witch will always return the
predefined value. But I would really like to be able to hide it completly.
Currently I do something like this:
class NameOfClass : NameOfBaseClass
{
NameOfClass()
{
base.PropertyName = PropertyName;
}
public new bool PropertyName
{
get
{
// return the default value
return true;
}
// no set method, we don't want it to change.
}
}
But I would realy like to be able to hide the property totally, because it
isn't needed anymore for my custom implementation of the new class/component
Something like:
class NameOfClass : NameOfBaseClass
{
NameOfClass()
{
base.PropertyName = true;
}
hide bool PropertyName;
}
Where the 'hide' keyword (or a 'remove' or 'delete' keyword, whatever)
whould hide the implementation of the base class.
Ofcourse this keyword would work somewhat similar as the 'new' keyword on a
method or property where the base class or code that uses the baseclasses
type, would still see the old implementation.
Is this a good idea, or am I missing some logic why this wouldn't be
possible or maybe a bad thing to implement?
I would really like to have an option to 'hide' a property or method from an
inherited class. For example when I create a subclass and supply a default
value for a property. Currently I create a new property, using the new
keyword, and only supply the get accessor witch will always return the
predefined value. But I would really like to be able to hide it completly.
Currently I do something like this:
class NameOfClass : NameOfBaseClass
{
NameOfClass()
{
base.PropertyName = PropertyName;
}
public new bool PropertyName
{
get
{
// return the default value
return true;
}
// no set method, we don't want it to change.
}
}
But I would realy like to be able to hide the property totally, because it
isn't needed anymore for my custom implementation of the new class/component
Something like:
class NameOfClass : NameOfBaseClass
{
NameOfClass()
{
base.PropertyName = true;
}
hide bool PropertyName;
}
Where the 'hide' keyword (or a 'remove' or 'delete' keyword, whatever)
whould hide the implementation of the base class.
Ofcourse this keyword would work somewhat similar as the 'new' keyword on a
method or property where the base class or code that uses the baseclasses
type, would still see the old implementation.
Is this a good idea, or am I missing some logic why this wouldn't be
possible or maybe a bad thing to implement?