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.1. Method modifiers

A C# method can have the modifiers listed in Table 7.1

Table 7.1. Valid method modifiers
Method modifierComments
newBesides using new to create new instances of a class, C# uses the same keyword for name hiding (in this case, method hiding) – a method declared with the new modifier hides (not overrides) an inherited method from the superclass of the same signature
abstractAn abstract C# method is similar to a Java abstract method
staticA static C# method is similar to a Java static method
overrideYou declare a method with the override modifier if this method is overriding a virtual method in the superclass
virtualA virtual method is one that can be overridden in a subclass
sealedA C# sealed method is similar to a Java final method ...

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