Please Consider this scenario:
We have a base class called clsMain :
class clsMain
{
int P1{set; get;}
int P2{set; get;}
int P3{set; get;}
string P4{set; get;}
string P5{set; get;}
}
and I want to have these 2 obejcts from clsMain :
object1 psudo code:
{
int P1{set; get;}
int P2{set; get;}
int P3{set; get;}
}
and :
object2 psudo code:
{
int P3{set; get;}
string P4{set; get;}
string P5{set; get;}
}
is it possible in c#? should I use specific type of class(abstract,…)?
thanks a lot
Inheritance is possible in C# as a first-class concept:
To
overridesomething, you need to make itvirtualand needs to have accessibility of anything other thanprivate.In your instance you could possibly do something like:
Though if I’m being honest, your question isn’t very clear. Note, however, that C# does not support multiple inheritance of classes.
Sounds like you want to filter out the properties. You cannot stop inherited members from being accessed (well, there is the
newmodifier, but this is sketchy at best). Instead you can use interfaces: