O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.10. Method overriding using the virtual and override Modifiers

There are some significant differences here between Java and C#. Method overriding in C# involves two keywords borrowed from C++ with no equivalents in Java – virtual and override. Take note of them carefully.

Like Java

  • Private methods in the superclass cannot be overridden in a subclass. If a subclass has a method of the same signature as a private method in the superclass, this is not considered to be a method override. [12]

    [12] Take note that if a method is declared as private in the superclass, and there is a method of the same signature (name and parameters only – the method signature excludes the return type) in the subclass, this does not constitute 'method overriding'. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required