Why is it not necessary to indicate ByVal/ByRef anymore?

Yogurtu picture Yogurtu · Feb 9, 2012 · Viewed 30.1k times · Source

I just installed Visual Studio 2010 Service pack (proposed on Windows Update), and I can see a new feature on the "intellisense" that means when I write a Function or Sub in VB.NET it doesn't auto-complete parameters with ByRef or ByVal...

1) Is there anyway that I can configure this option back to how it was before?

2) If I don't specify ByX, which one is used by default? (it seems like it is always ByRef)

Answer

Tim Schmelter picture Tim Schmelter · Feb 9, 2012

It seems that this post covers your question:

http://msmvps.com/blogs/carlosq/archive/2011/03/15/vs-2010-sp1-changing-quot-byval-quot-vb-net-code-editor-experience.aspx

So no, there is no way to get the old behaviour. From now on ByVal is the default (what it was before) and it won't get added automatically to the method parameters.

In my opinion this is a good decision since it's making VB.NET a bit more consistent with C# and avoids unnecessary "noises"(it's already verbose enough).

Old behaviour:

Private Sub test(ByVal test As String)
End Sub

New behaviour

Private Sub test(test As String)
End Sub