G
g18c
Hi, im trying to do something and just been caught off guard. I want
to implement an interface but only for certain class, but of course
when i derive from this base class the derived class also inherits the
interface.
public class Base : IGetType
{
protected byte m_type;
object IGetType.TypeIdentifier
{
get { return m_type; }
}
}
public class Base2 : Base
{
}
void TestingFunc()
{
object obj = new Base2();
if (obj is IGetType)
{
// Base2 implements IGetType
}
}
I am checking objects because i am doing a recursive check against
arbitary types to see if they implement the interface. Now i want Base
to implement the interface, but not inherit it to Base2. Furthermore i
do need Base2 to inherit from Base. I know that is the definition of
inheritance, so maybe someone would be kind enough to think about how
else i could do this?
Many thanks,
Chris
to implement an interface but only for certain class, but of course
when i derive from this base class the derived class also inherits the
interface.
public class Base : IGetType
{
protected byte m_type;
object IGetType.TypeIdentifier
{
get { return m_type; }
}
}
public class Base2 : Base
{
}
void TestingFunc()
{
object obj = new Base2();
if (obj is IGetType)
{
// Base2 implements IGetType
}
}
I am checking objects because i am doing a recursive check against
arbitary types to see if they implement the interface. Now i want Base
to implement the interface, but not inherit it to Base2. Furthermore i
do need Base2 to inherit from Base. I know that is the definition of
inheritance, so maybe someone would be kind enough to think about how
else i could do this?
Many thanks,
Chris