vb.net – 为什么不需要再指示ByVal/ByRef?

我刚刚安装了Visual Studio 2010 Service Pack(在Windows Update上提出),我可以看到“Intellisense”上的一个功能,这意味着当我在VB.NET中编写一个Function或Sub时,它不会使用ByRef自动完成参数或ByVal …

1)有没有可以配置这个选项回到之前呢?

2)如果我不指定ByX,认使用哪一个? (似乎总是ByRef)

Tim涵盖了您直接询问的内容,但要注意的其他事项是,任何引用类型变量(如用户定义的类即使通过值传递)也将允许您对该实例属性等进行更改。然而,它不会允许您更改整个对象。这可能是为什么你似乎认通过引用
Public Sub (Something As WhateverClass) 
  Something = New WhateverClass 'will result in no changes when outside this method

  Something.Property1 = "Test"  'will result in an updated property when outside this method
End Sub

MSDN

The value of a reference type is a pointer to the data elsewhere in memory. This means that when you pass a reference type by value,the procedure code has a pointer to the underlying element’s data,even though it cannot access the underlying element itself. For example,if the element is an array variable,the procedure code does not have access to the variable itself,but it can access the array members.

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...