In C#, if I have an object that is inherited from another object, and I have a list of the inherited object, how can I call a function in the base class?
Here is an example:
class testObject
{
public void testFunction()
{
}
}
class testObject2 : testObject
{
public void testFunction()
{
}
}
Here is the list:
List<testObject> testObjects
If I add some testObject2
objects to the list, how can I call the testFunction
function
for each testObject2
object? If I try and call testFunction
for each object, the testFunction
in the testObject
is called.
EDIT
When adding the override code to the testFunction
in testObject2
, I am getting this error:
cannot override inherited member because it is not marked virtual, abstract, or override