问题描述
我刚拿起John Robbins的调试书副本,开始在反汇编代码中查看
。无论如何,我讨厌VB中的可选参数,但是我检查它们是为了看看IL是什么创建的。我之前用
模块完成了这项工作,并看到< gasp>它们的行为就像只有
静态成员的密封类。
无论如何,看起来可选参数只不过是告诉
的一种方式
编译器为你写一些重载。所以,在子程序的情况下,我看到b $ b看到有15个可选参数(不,我没写过)
它看起来像IL显示了15种重载方法。我绝不是一个
专家,但如果是这样的话......我是否正确,这有点伤痕?
我提到过对于那个写它的人来说,他说我离开了我的摇杆。
据他说,这是VB.NET优于C#的好处之一,因为你
不必使用广泛的重载,而且效率更高。从
IL来看,这看起来恰恰相反。
因此,如果没有激发VB.NET与C#的争论,我是否会写这个或者是我好吗?b $ b读错了吗?
谢谢,
比尔
I just picked up a copy of John Robbins'' debugging book and started to look
at disassembled code. Anyway, I hate optional Parameters in VB, but I was
checking them out to see what IL is created. I''ve done this before with
Modules, and saw that <gasp> they behave just like sealed classes with only
static members.
Anyway, it looks like Optional Parameters are nothing but a way to tell the
compiler to write some overloads for you. So, in the case of a Subroutine I
was looking at that had 15 optional parameters (and no, I didn''t write it)
it looked like the IL was showing 15 overloaded methods. I''m by no means an
Expert, but if this is the case...am I right in that it''s kind of scarry?
I mentioned this to the guy who wrote it and he said I''m off of my rocker.
According to him, this is one of the benefits of VB.NET over C# in that you
don''t have to use extensive overloading and it''s more efficient. From the
IL though, this looks like the opposite.
So without stirring a VB.NET vs. C# debate, am I write about this or am I
reading it wrong?
Thanks,
Bill
推荐答案
这篇关于可选参数 - 真正发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!