[Mono-list] Re: Final method in C# (as the final keyword in Java)

Jonathan Pryor jonpryor at vt.edu
Sun Jun 4 12:55:18 EDT 2006


On Tue, 2006-05-30 at 17:14 +0200, Ympostor wrote:
> By default, all methods are non-virtual. So, as it is hasn't got the 
> virtual keyword, it is non-virtual already, am I right? 

Not quite.  `virtual' means `dynamic method dispatch' (i.e. the actual
method that is invoked is determined at runtime), and a method can be
marked `virtual' using *either* the `virtual' C# keyword *or* the
`abstract' C# keyword (when placed on a method).

So your DontOverrideMe() method is virtual, even though it doesn't use
the `virtual' keyword (`abstract' in this context means "virtual but
must be overridden in a derived class").

 - Jon




More information about the Mono-list mailing list