I have learned quite a bit browsing through Hidden Features of C# and was surprised when I couldn't find something similar for VB.NET.
So what are some of its hidden or lesser known features?
I have learned quite a bit browsing through Hidden Features of C# and was surprised when I couldn't find something similar for VB.NET.
So what are some of its hidden or lesser known features?
I really like the "My" Namespace which was introduced in Visual Basic 2005. My is a shortcut to several groups of information and functionality. It provides quick and intuitive access to the following types of information:
Have you noticed the Like comparison operator?
Dim b As Boolean = "file.txt" Like "*.txt"
More from MSDN
The best and easy CSV parser:
By adding a reference to Microsoft.VisualBasic, this can be used in any other .Net language, e.g. C#
Forcing ByVal
In VB, if you wrap your arguments in an extra set of parentheses you can override the ByRef declaration of the method and turn it into a ByVal. For instance, the following code produces 4, 5, 5 instead of 4,5,6
See Argument Not Being Modified by Procedure Call - Underlying Variable
You can have 2 lines of code in just one line. hence:
The
Exception When
clause is largely unknown.Consider this: