所有方法都是虚拟的? [英] All methods are virtual?

查看:77
本文介绍了所有方法都是虚拟的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这个网站页面上看到了这一点
http ://www.vbip.com/books/1861004915...r_4915_06.asp:

与许多面向对象语言不同,VB.NET中的所有方法都是虚拟的。


现在在BOL中,在.NET应用程序的Perforamce技巧和诀窍中,一个.Net

开发者平台白皮书,在最底层,它说:


JIT无法内联虚拟方法,因此如果你摆脱非虚拟方法,你将失去潜在的优化




这是否意味着用VB编写的任何方法都无法内联,因为它们将b $ b编译为虚拟?如果是这样,那么NotInheritable的目的是什么,或者

NotOverridable?


如果有人可以指我到某个地方帮助我理解这个

离婚,我将不胜感激。到目前为止,我一直都明白,如果没有明确声明,VB.Net方法不是虚拟的,因为

可以覆盖,因此有可能被内联。


Raymond Lewallen

联邦航空管理局

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

推荐答案

Raymond Lewallen< Ra的****************** @ nospam.faa.gov>写道:
Raymond Lewallen <Ra******************@nospam.faa.gov> wrote:
我在这个网站页面上看到这个
http://www.vbip.com/books/1861004915...r_4915_06.asp:

与许多面向对象语言不同,VB中的所有方法。 NET是虚拟的。
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.




这是错的 - 至少我认为虚拟的意思是什么。是
(即它可以被覆盖)。


它甚至在早些时候说过默认方法不能被覆盖。


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复群组,请不要邮寄我也是



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


这是正确的,方法必须明确标记''Overridable''


问候


-


OHM(特里伯恩斯)

。 。 。单手人。 。

如果你需要我的电子邮件,请问我


当你不知道自己在做什么时,过得很快


" Jon Skeet [C#MVP]" < SK *** @ pobox.com>在消息中写道

新闻:MP ************************ @ msnews.microsoft.c om ...
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>写道:
Raymond Lewallen <Ra******************@nospam.faa.gov> wrote:
我在这个网站页面上看到这个
http://www.vbip.com/books/1861004915...r_4915_06.asp:

与许多面向对象语言不同,VB中的所有方法。 NET是
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


虚拟。
这是错的 - 至少我认为虚拟的意思是什么。
(即它可以被覆盖)。

它甚至在早些时候说过默认方法不能被覆盖。

- < Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet
如果回复小组,请不要给我发邮件

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



所以我的假设是正确的,默认情况下,VB方法不是虚拟的
,这是我一直以来的理解吗?
So am I correct in my assumption that by default, VB methods are NOT
virtual, which is how I''ve always understood it?


这篇关于所有方法都是虚拟的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆