7.1. Method modifiers
A C# method can have the modifiers listed in Table 7.1
Method modifier | Comments |
---|---|
new | Besides 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 |
abstract | An abstract C# method is similar to a Java abstract method |
static | A static C# method is similar to a Java static method |
override | You declare a method with the override modifier if this method is overriding a virtual method in the superclass |
virtual | A virtual method is one that can be overridden in a subclass |
sealed | A C# sealed method is similar to a Java final method ... |
Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.