By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,503 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

All methods are virtual?

P: n/a
I read this on this website page
http://www.vbip.com/books/1861004915...r_4915_06.asp:

Unlike many object-oriented languages, all methods in VB.NET are virtual.

Now in BOL, Under Perforamce Tips and Tricks in .NET Applications, A .Net
Developer Platform White Paper, at the very bottom, it says:

The JIT cannot inline virtual methods, so you lose a potential optimization
if you get rid of non-virtual methods.

So does this mean any method written in VB cannot be inlined, because they
are compiled as virtual? If so, whats the purpose of NotInheritable, or
NotOverridable?

If someone can point me to someplace that will help me on understanding this
discrepency, I would appreciate it. To this point, I've always understood
that VB.Net methods were not virtual if not declared explicitly as
Overridable, and could therefore have the possibility of being inlined.

Raymond Lewallen
Federal Aviation Administration
Nov 21 '05 #1
Share this Question
Share on Google+
20 Replies


P: n/a
Raymond Lewallen <Ra******************@nospam.faa.gov> wrote:
I read this on this website page
http://www.vbip.com/books/1861004915...r_4915_06.asp:

Unlike many object-oriented languages, all methods in VB.NET are virtual.


It's wrong - at least by what I consider the meaning of "virtual" to be
(namely that it can be overridden).

It even says earlier on that by default methods can't be overridden.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 21 '05 #2

P: n/a
This is correct, methods must be explicitly marked 'Overridable'

Regards

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Raymond Lewallen <Ra******************@nospam.faa.gov> wrote:
I read this on this website page
http://www.vbip.com/books/1861004915...r_4915_06.asp:

Unlike many object-oriented languages, all methods in VB.NET are
virtual.
It's wrong - at least by what I consider the meaning of "virtual" to be
(namely that it can be overridden).

It even says earlier on that by default methods can't be overridden.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 21 '05 #3

P: n/a
So am I correct in my assumption that by default, VB methods are NOT
virtual, which is how I've always understood it?
Nov 21 '05 #4

P: n/a
Raymond Lewallen <Ra******************@nospam.faa.gov> wrote:
So am I correct in my assumption that by default, VB methods are NOT
virtual, which is how I've always understood it?


Yup.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 21 '05 #5

P: n/a
* "Raymond Lewallen" <Ra******************@nospam.faa.gov> scripsit:
So does this mean any method written in VB cannot be inlined, because they
are compiled as virtual? If so, whats the purpose of NotInheritable, or
NotOverridable?
'NotOverridable' is the default. You don't need to explicitly write it
in every method's head.
If someone can point me to someplace that will help me on understanding this
discrepency, I would appreciate it. To this point, I've always understood
that VB.Net methods were not virtual if not declared explicitly as
Overridable, and could therefore have the possibility of being inlined.


You are right -- the author of the text you mentioned is wrong.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #6

P: n/a
> * "Raymond Lewallen" <Ra******************@nospam.faa.gov> scripsit:
So does this mean any method written in VB cannot be inlined, because they are compiled as virtual? If so, whats the purpose of NotInheritable, or
NotOverridable?


'NotOverridable' is the default. You don't need to explicitly write it
in every method's head.


That is wrong. 'NotOverridable' means sealed in C# which is not the default
and must be written explicitly.
'NotOverridable' means a method cannot be overridden even if it is ifself a
virtual method.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 21 '05 #7

P: n/a
> > Unlike many object-oriented languages, all methods in VB.NET are
virtual.

It's wrong - at least by what I consider the meaning of "virtual" to be
(namely that it can be overridden).


The author also claims that
" If all constructor methods of the base class require parameters then we
must implement at least one constructor in our subclass and we must
explicitly call MyBase.New from within our constructors. "

In my knowledge we must provide for each ctor of the baseclass a ctor of the
derived class which then calls the base class ctor.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 21 '05 #8

P: n/a
cody <pl*************************@gmx.de> wrote:
It's wrong - at least by what I consider the meaning of "virtual" to be
(namely that it can be overridden).
The author also claims that
" If all constructor methods of the base class require parameters then we
must implement at least one constructor in our subclass and we must
explicitly call MyBase.New from within our constructors. "


That's true, I believe. Can you give a counter-example? For instance,
can you provide a class with no constructor specified but which derives
from:

public class Foo
{
public Foo (int i)
{
}
}

?
In my knowledge we must provide for each ctor of the baseclass a ctor of the
derived class which then calls the base class ctor.


Not at all. Every constructor in the derived class must call a base
class constructor, but there's nothing to say that you *have* to have
as many derived class constructors as there are base class
constructors.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 21 '05 #9

P: n/a
Cody,

My original post concerned VB, which is what Herfried was referring to, and
he was correct in his post. In VB, NotOverridable is the default. I'm not
sure about C#, as I do 90% of my programming in VB.

Raymond Lewallen
Federal Aviation Administration

"cody" <pl*************************@gmx.de> wrote in message
news:u2**************@tk2msftngp13.phx.gbl...
* "Raymond Lewallen" <Ra******************@nospam.faa.gov> scripsit:
So does this mean any method written in VB cannot be inlined, because they are compiled as virtual? If so, whats the purpose of NotInheritable, or NotOverridable?
'NotOverridable' is the default. You don't need to explicitly write it
in every method's head.


That is wrong. 'NotOverridable' means sealed in C# which is not the

default and must be written explicitly.
'NotOverridable' means a method cannot be overridden even if it is ifself a virtual method.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk

Nov 21 '05 #10

P: n/a
> The author also claims that
" If all constructor methods of the base class require parameters then we
must implement at least one constructor in our subclass and we must
explicitly call MyBase.New from within our constructors. "
This is true. You do have to call a base constructor.
In my knowledge we must provide for each ctor of the baseclass a ctor of the derived class which then calls the base class ctor.


This is not true. You can have only one constructor in your derived class
and many constructors in your base class. You just need to call at least
one of the base constructors.

Raymond Lewallen
Federal Aviation Administration
Nov 21 '05 #11

P: n/a
* "cody" <pl*************************@gmx.de> scripsit:
are compiled as virtual? If so, whats the purpose of NotInheritable, or
NotOverridable?
'NotOverridable' is the default. You don't need to explicitly write it
in every method's head.


That is wrong. 'NotOverridable' means sealed in C# which is not the default
and must be written explicitly.


That's wrong!

In VB.NET, 'NotOverridable' is applied to methods automatically. Just
add a method to a class and take a look at it in object browser.

\\\
Public Class Bar

' Implicitly 'NotOverridable'.
Public Sub Goo()
...
End Sub
End Class

Public Class FooBar
Inherits Bar

' Compile time error:
' Cannot override method that is not marked as 'Overridable' in the base class.
Public Overrides Sub Goo()
...
End Sub
End Class
///
'NotOverridable' means a method cannot be overridden even if it is ifself a
virtual method.


'Overridable' (VB.NET) = 'virtual' (C#). 'NotOverridable' (VB.NET) =
'sealed' (C#) is the opposite of 'Overridable'. 'NotOverridable' is the
default in VB.NET. 'sealed' is not the default in C#.

Making 'NotOverridable' the default has the advantage that the inheritor
cannot override a method to change its behavior if that's not the
intention of the base class' author to allow this. Thus 'Overridable'
must be specified explicitly in VB.NET.

Yes -- there are differences between VB.NET and C#, and I think that the
way the VB.NET team has chosen in this case is the preferred way.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #12

P: n/a
On 2004-08-25, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:
* "cody" <pl*************************@gmx.de> scripsit:
are compiled as virtual? If so, whats the purpose of NotInheritable, or
NotOverridable?

'NotOverridable' is the default. You don't need to explicitly write it
in every method's head.
That is wrong. 'NotOverridable' means sealed in C# which is not the default
and must be written explicitly.


That's wrong!


No, it's correct.
In VB.NET, 'NotOverridable' is applied to methods automatically. Just
add a method to a class and take a look at it in object browser.
Or better, look at it in the IL, and you'll see it's not there.

A lot of this is just semantics, but it's still significant. There's a
difference between a method which is "Not Overridable" and the
"NotOverridable" keyword.

By default, VB methods are "not overridable". However, the
NotOverridable keyword does something slightly different and may only be
applied to virtual methods.

'NotOverridable' is the
default in VB.NET.
No, it's not. The default for virtual methods overrides (i.e., with the
Overrides keyword) is Overridable. In fact, try typing

Public Sub Overridable Overrides MyMethod()

and you'll find this out. The compiler specifically says that the
method is implicitly overridable. If you wish to "seal" the virtual
method in a specific subclass, then you must explicitly use the
NotOverridable keyword.

For non-virtual methods, by default they cannot be overridden, but the
NotOverridable keyword simply doesn't apply.
'sealed' is not the default in C#.

Making 'NotOverridable' the default has the advantage that the inheritor
cannot override a method to change its behavior if that's not the
intention of the base class' author to allow this. Thus 'Overridable'
must be specified explicitly in VB.NET.
Just as C# methods must be explicitly virtual, so to VB.Net methods must
be explicitly Overridable. But if you override a method, and wish to
stop subclasses from overriding your implementation, you must be
explicit about this: with NotOverridable in VB.Net and sealed in C#.

Yes -- there are differences between VB.NET and C#, and I think that the
way the VB.NET team has chosen in this case is the preferred way.


There are differences between VB.Net and C#, but this isn't one of them.
Nov 21 '05 #13

P: n/a
Take the following:

Public Class Foo
Public Sub Bar()
End Sub
End Class

Public Class Moo
Inherits Foo
Public Overrides Sub Bar()
End Sub
End Class

It won't compile. You get a build error. 'Bar' overrides a sub in the base
class 'Foo' that is not declared 'Overridable'. It won't compile because
Foo.Bar() is not a virtual method, so back to original question this is all
working as expected. I understand that you can't apply NotOverridalbe to a
method that itself is not a virtual method, but both give the same expected
results... a non-virtual method. So the basic, in-general answer is yes,
all VB.Net methods are non-virtual by default, and only virtual methods can
be made non-virtual using the NotOverridable keyword.
"David" <df*****@woofix.local.dom> wrote in message
news:slrnciqilj.cn4.df*****@woofix.local.dom...
On 2004-08-25, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:
* "cody" <pl*************************@gmx.de> scripsit:
> are compiled as virtual? If so, whats the purpose of NotInheritable, or> NotOverridable?

'NotOverridable' is the default. You don't need to explicitly write it in every method's head.

That is wrong. 'NotOverridable' means sealed in C# which is not the default and must be written explicitly.


That's wrong!


No, it's correct.
In VB.NET, 'NotOverridable' is applied to methods automatically. Just
add a method to a class and take a look at it in object browser.


Or better, look at it in the IL, and you'll see it's not there.

A lot of this is just semantics, but it's still significant. There's a
difference between a method which is "Not Overridable" and the
"NotOverridable" keyword.

By default, VB methods are "not overridable". However, the
NotOverridable keyword does something slightly different and may only be
applied to virtual methods.

'NotOverridable' is the
default in VB.NET.


No, it's not. The default for virtual methods overrides (i.e., with the
Overrides keyword) is Overridable. In fact, try typing

Public Sub Overridable Overrides MyMethod()

and you'll find this out. The compiler specifically says that the
method is implicitly overridable. If you wish to "seal" the virtual
method in a specific subclass, then you must explicitly use the
NotOverridable keyword.

For non-virtual methods, by default they cannot be overridden, but the
NotOverridable keyword simply doesn't apply.
'sealed' is not the default in C#.

Making 'NotOverridable' the default has the advantage that the inheritor
cannot override a method to change its behavior if that's not the
intention of the base class' author to allow this. Thus 'Overridable'
must be specified explicitly in VB.NET.


Just as C# methods must be explicitly virtual, so to VB.Net methods must
be explicitly Overridable. But if you override a method, and wish to
stop subclasses from overriding your implementation, you must be
explicit about this: with NotOverridable in VB.Net and sealed in C#.

Yes -- there are differences between VB.NET and C#, and I think that the
way the VB.NET team has chosen in this case is the preferred way.


There are differences between VB.Net and C#, but this isn't one of them.

Nov 21 '05 #14

P: n/a
* "Raymond Lewallen" <Ra******************@nospam.faa.gov> scripsit:
Take the following:

Public Class Foo
Public Sub Bar()
End Sub
End Class

Public Class Moo
Inherits Foo
Public Overrides Sub Bar()
End Sub
End Class

It won't compile. You get a build error. 'Bar' overrides a sub in the base
class 'Foo' that is not declared 'Overridable'. It won't compile because
Foo.Bar() is not a virtual method, so back to original question this is all
working as expected. I understand that you can't apply NotOverridalbe to a
method that itself is not a virtual method, but both give the same expected
results... a non-virtual method. So the basic, in-general answer is yes,
all VB.Net methods are non-virtual by default, and only virtual methods can
be made non-virtual using the NotOverridable keyword.


Great explanation! That's what I was talking about.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #15

P: n/a
* David <df*****@woofix.local.dom> scripsit:
> are compiled as virtual? If so, whats the purpose of NotInheritable, or
> NotOverridable?

'NotOverridable' is the default. You don't need to explicitly write it
in every method's head.

That is wrong. 'NotOverridable' means sealed in C# which is not the default
and must be written explicitly.
That's wrong!


No, it's correct.


It's not correct.

I think we are talking about different things.

What I want to say is that 'NotOverridable' says that a procedure cannot
be overridden by a derived class. 'NotOverridable' is the default for
procedures that do not override a procedure in the base class.
In VB.NET, 'NotOverridable' is applied to methods automatically. Just
add a method to a class and take a look at it in object browser.


Or better, look at it in the IL, and you'll see it's not there.

A lot of this is just semantics, but it's still significant. There's a
difference between a method which is "Not Overridable" and the
"NotOverridable" keyword.


The 'NotOverridable' keyword is overloaded in its meaning. On the one
hand, it's implicitly applied to methods that do not override a
procedure defined in the base class. In this case, you /must not/
specify 'NotOverridable', but it's applied automatically. It's the
default. On the other hand, 'NotOverridable' can be specified to
prevent a base class' method from being overridden in a derived class.
By default, VB methods are "not overridable". However, the
NotOverridable keyword does something slightly different and may only be
applied to virtual methods.
It's implicitly applied to methods that do not override a base class'
method too. That's what the docs say
(<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vastmsub.asp>).
'NotOverridable' is the
default in VB.NET.


No, it's not. The default for virtual methods overrides (i.e., with the
Overrides keyword) is Overridable. In fact, try typing


Who is talking about overridable methods? This discussion is about the
question if methods in VB.NET can be overridden by default. The answer
is "no".
Public Sub Overridable Overrides MyMethod()

and you'll find this out. The compiler specifically says that the
method is implicitly overridable. If you wish to "seal" the virtual
method in a specific subclass, then you must explicitly use the
NotOverridable keyword.
I never said anything else. I am just talking about something
different.
For non-virtual methods, by default they cannot be overridden, but the
NotOverridable keyword simply doesn't apply.


It does, but implicitly only.
Yes -- there are differences between VB.NET and C#, and I think that the
way the VB.NET team has chosen in this case is the preferred way.


There are differences between VB.Net and C#, but this isn't one of them.


Sorry, I mixed something up. 'virtual' is mandatory to be able to override
a method in C#.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #16

P: n/a
On 2004-08-26, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:
* David <df*****@woofix.local.dom> scripsit:
>> are compiled as virtual? If so, whats the purpose of NotInheritable, or
>> NotOverridable?
>
> 'NotOverridable' is the default. You don't need to explicitly write it
> in every method's head.

That is wrong. 'NotOverridable' means sealed in C# which is not the default
and must be written explicitly.

That's wrong!


No, it's correct.


It's not correct.

I think we are talking about different things.

What I want to say is that 'NotOverridable' says that a procedure cannot
be overridden by a derived class. 'NotOverridable' is the default for
procedures that do not override a procedure in the base class.
In VB.NET, 'NotOverridable' is applied to methods automatically. Just
add a method to a class and take a look at it in object browser.


Or better, look at it in the IL, and you'll see it's not there.

A lot of this is just semantics, but it's still significant. There's a
difference between a method which is "Not Overridable" and the
"NotOverridable" keyword.


The 'NotOverridable' keyword is overloaded in its meaning.


As I said originally, some of this is simply semantics. It's a
different model of thinking for the same problem. Since we both agree
that an instance method declared with no modifiers can't be overridden,
the only question is how to best explain that. I think of that as
different than sealed/NotOverridable, while you explain it as
illustrating an overloaded meaning of NotOverridable that may only be
used implicitly.

I don't think there's any final answer here, it's a question of which
explanation is easier to understand, but I prefer my model of
explanation for these reasons:

1. NotOverridable, when used explicitly, has an equivalent in the IL
(final), which does not appear in normal instance methods.

2. I'm coming from more of a c++ background where I immediately think
vtable when I hear virtual. Saying that NotOverridable is the default
makes very little sense in this context.

3. Saying that a keyword has an overloaded meaning that only exists
when used implicitly doesn't really click for me, it seems
contradictory.
By default, VB methods are "not overridable". However, the
NotOverridable keyword does something slightly different and may only be
applied to virtual methods.


It's implicitly applied to methods that do not override a base class'
method too. That's what the docs say
(<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vastmsub.asp>).


I've seen that. What's interesting is that the C# spec (as well as the
IL documentation) defines the *exact* same concept in a different way.
I presume the documentation folks tested this stuff and found that the
different explanations were more suited to different groups. I suspect
that's related to the vtable thing I mentioned above.
Yes -- there are differences between VB.NET and C#, and I think that the
way the VB.NET team has chosen in this case is the preferred way.


There are differences between VB.Net and C#, but this isn't one of them.


Sorry, I mixed something up. 'virtual' is mandatory to be able to override
a method in C#.


Yes, the two main reasons I posted originally was your "that's wrong!"
in response to a post that had nothing inaccurate in its content at all
seemed likely to confuse people, and your misstatement of the exact same
situation in C# implied that you didn't understand what was going on.

Nov 21 '05 #17

P: n/a
On 2004-08-26, Raymond Lewallen <Ra******************@nospam.faa.gov> wrote:
Take the following:

Public Class Foo
Public Sub Bar()
End Sub
End Class

Public Class Moo
Inherits Foo
Public Overrides Sub Bar()
End Sub
End Class

It won't compile. You get a build error. 'Bar' overrides a sub in the base
class 'Foo' that is not declared 'Overridable'. It won't compile because
Foo.Bar() is not a virtual method, so back to original question this is all
working as expected. I understand that you can't apply NotOverridalbe to a
method that itself is not a virtual method, but both give the same expected
results... a non-virtual method. So the basic, in-general answer is yes,
all VB.Net methods are non-virtual by default, and only virtual methods can
be made non-virtual using the NotOverridable keyword.


Yes, what's kinda funny is that despite all the apparent disagreements
in the last few posts nobody disagrees with the above. I think the only
thing in your original post that was misleading was the statement that
"you don't need to write it [NotOverridable] explictly". This implies
that you *could* write it explicitly on ordinary methods, which of
course you can't.
Nov 21 '05 #18

P: n/a
David,

* David <df*****@woofix.local.dom> scripsit:
In VB.NET, 'NotOverridable' is applied to methods automatically. Just
add a method to a class and take a look at it in object browser.

Or better, look at it in the IL, and you'll see it's not there.

A lot of this is just semantics, but it's still significant. There's a
difference between a method which is "Not Overridable" and the
"NotOverridable" keyword.
The 'NotOverridable' keyword is overloaded in its meaning.


As I said originally, some of this is simply semantics. It's a
different model of thinking for the same problem. Since we both agree
that an instance method declared with no modifiers can't be overridden,
the only question is how to best explain that. I think of that as
different than sealed/NotOverridable, while you explain it as
illustrating an overloaded meaning of NotOverridable that may only be
used implicitly.


ACK.
I don't think there's any final answer here, it's a question of which
explanation is easier to understand, but I prefer my model of
explanation for these reasons:
I never tried to give an explanation that is easy to understand. My
intention was to follow the usage of terminomogy as it's done in the
documentation.
1. NotOverridable, when used explicitly, has an equivalent in the IL
(final), which does not appear in normal instance methods.

2. I'm coming from more of a c++ background where I immediately think
vtable when I hear virtual. Saying that NotOverridable is the default
makes very little sense in this context.

3. Saying that a keyword has an overloaded meaning that only exists
when used implicitly doesn't really click for me, it seems
contradictory.


Well, we are talking about VB.NET. I have stopped using words like
"static", "virtual" and "sealed" some times ago because they only cause
confusion in the context of VB.NET programming. There are other words,
with other semantics. And, I agree with you, 'NotOverridable' maps to
'sealed' in C* semantics, but it doesn't in matters of VB.NET semantics.

It's all just about the fact that VB.NET can stand on its own feet. It
doesn't need to borrow terms from the C* terminology.
It's implicitly applied to methods that do not override a base class'
method too. That's what the docs say
(<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vastmsub.asp>).


I've seen that. What's interesting is that the C# spec (as well as the
IL documentation) defines the *exact* same concept in a different way.
I presume the documentation folks tested this stuff and found that the
different explanations were more suited to different groups. I suspect
that's related to the vtable thing I mentioned above.


That's what I was thinking about too. My suggestion is to encourage
both groups, VB.NETies and C#ies, to use their own terminology and
making them aware of the fact that there is no 1:1 mapping between them.

It's always interesting to see that different terminology and background
causes confusion :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #19

P: n/a
* David <df*****@woofix.local.dom> scripsit:
It won't compile. You get a build error. 'Bar' overrides a sub in the base
class 'Foo' that is not declared 'Overridable'. It won't compile because
Foo.Bar() is not a virtual method, so back to original question this is all
working as expected. I understand that you can't apply NotOverridalbe to a
method that itself is not a virtual method, but both give the same expected
results... a non-virtual method. So the basic, in-general answer is yes,
all VB.Net methods are non-virtual by default, and only virtual methods can
be made non-virtual using the NotOverridable keyword.


Yes, what's kinda funny is that despite all the apparent disagreements
in the last few posts nobody disagrees with the above. I think the only
thing in your original post that was misleading was the statement that
"you don't need to write it [NotOverridable] explictly". This implies
that you *could* write it explicitly on ordinary methods, which of
course you can't.


That's indeed weird. I would expect that it was possible to specify
'NotOverridable' in this situation too. The object browser of VB/VS.NET
2002 displays those methods as 'NotOverridable', despite the fact that
'NotOverridable' must not be specified by the programmer in this context.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #20

P: n/a
On 2004-08-26, Herfried K. Wagner [MVP] <hi***************@gmx.at> wrote:

Well, we are talking about VB.NET. I have stopped using words like
"static", "virtual" and "sealed" some times ago because they only cause
confusion in the context of VB.NET programming. There are other words,
with other semantics. And, I agree with you, 'NotOverridable' maps to
'sealed' in C* semantics, but it doesn't in matters of VB.NET semantics.

It's all just about the fact that VB.NET can stand on its own feet. It
doesn't need to borrow terms from the C* terminology.
<rant intensity="medium">

This is actually an area that really annoys me about VB.Net. Words like
virtual and abstract aren't "C#" terms, they're CS terms; they're used
in pretty much every major OO text you'll find, and used to describe
pretty much every OO language out there. I may program in VB.Net these
days, but of the last four programming books I've read, 2 were focused
on java, one on C#, and one was multi-language.

Inventing completely new nomenclature doesn't make these things easier
to learn, it just makes it harder for VB.Net programmers to take
advantage of the vast amount of literature out there.

</rant>
It's implicitly applied to methods that do not override a base class'
method too. That's what the docs say
(<URL:http://msdn.microsoft.com/library/en-us/vblr7/html/vastmsub.asp>).


We've already driven this issue into the ground, but it's interesting
that the actual language spec doesn't back up this part of the
documentation at all...

http://msdn.microsoft.com/library/en...bspec7_1_3.asp

"The NotOverridable modifier indicates that an overridable method cannot
be further overridden"

"NotOverridable cannot be combined with Overridable or MustOverride and
must be combined with Overrides."

Nothing there about anything being NotOverridable by default.

Nov 21 '05 #21

This discussion thread is closed

Replies have been disabled for this discussion.