Take the 2-minute tour ×

I know that when we have a virtual function in our own base class, then by overriding it in a derived class and considering casting when variable declaration, we have different result with comparison to using new modifier in the derived class. but why? Is there any logical reason for that or we have to learn it without any reason?

share|improve this question
an example of what you are asking about would make the question clearer –  anon Jul 7 '09 at 8:38
add comment

2 Answers

I assume you are referring to C#.

Basically, you use the new modifier when the subclass method has nothing to do with the superclass method. They share the name, but there is no shared polymorphic behavior. When you are polymorphically redefining the name, that is called overriding.

share|improve this answer
add comment

Instead of using the new operator I would recommend choosing a different name for the method.

share|improve this answer
add comment

Your Answer


