Assume all the property for the Base class can't fit exactly for the Sub
class.
I mean some of the property for the Base class is wrong for the Sub class is
it then allowed
to inherit from class Base.
These other guys are correct in that inheritance may not be the way to go
here. But if you absolutely must inherit Sub from Base, you can always hide
the properties in Base that you don't want to appear in Sub with the "new"
keyword then mark them private.
For example, assume you don't want the "BaseProp" property to be visible in
the Sub class:
public class Base
{
private int m_BaseProp;
public int BaseProp
{
get
{
return this.m_BaseProp;
}
set
{
this.m_BaseProp = value;
}
}
}
public class Sub : Base
{
new private int BaseProp
{
get
{
return base.BaseProp;
}
set
{
base.BaseProp = value;
}
}
}
--
Timm Martin
Mini-Tools
..NET Components and Windows Software
http://www.mini-tools.com