7.1 Method modifiers


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

Table 7.1. Valid method modifiers

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 “ the sealed modifier is usually used together with the override modifier (see section 7.13)

public

Access modifiers (see section 8.1)

protected

internal

private



From Java to C#. A Developers Guide
From Java to C#: A Developers Guide
ISBN: 0321136225
EAN: 2147483647
Year: 2003
Pages: 221
Authors: Heng Ngee Mok

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net