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?
Oh! and don't forget XML Literals.
Object initialization is in there too!
Passing parameters by name and, so reordering them
Usage:
Can also be called using the ":=" parameter specification in any order:
If
conditional and coalesce operatorIt's not so much hidden as deprecated! VB 9 has the
If
operator which is much better and works exactly as C#'s conditional and coalesce operator (depending on what you want):Edited to show another example:
This will work with
If()
, but cause an exception withIIf()
One major time saver I use all the time is the With keyword:
I just don't like typing more than I have to!
I just found an article talking about the "!" operator, also know as the "dictionary lookup operator". Here's an excerpt from the article at: http://panopticoncentral.net/articles/902.aspx