D
Dennis Myrén
If you know all the dervied objects and they are not too many,
i suggest the easiest way which is checking what type it is.
if (node is Num)
{
((Num) node).Something();
}
else if (node is AnotherDerived)
{
((AnotherDerived) node).SomethingElse();
}
or if some of the derivors share the same functions you could have another
base class on top
of Node.
if (node is ExtensionNode)
{
((ExtensionNode) node).Something();
}
or have them implement an interface or something.
If this is not an option for you, the only way is to use reflection to
dynamically call members,
but then you would need to know the name of the member to call anyway.
i suggest the easiest way which is checking what type it is.
if (node is Num)
{
((Num) node).Something();
}
else if (node is AnotherDerived)
{
((AnotherDerived) node).SomethingElse();
}
or if some of the derivors share the same functions you could have another
base class on top
of Node.
if (node is ExtensionNode)
{
((ExtensionNode) node).Something();
}
or have them implement an interface or something.
If this is not an option for you, the only way is to use reflection to
dynamically call members,
but then you would need to know the name of the member to call anyway.