Basically, I have a function that has an optional dictionary argument. Since it’s optional, it needs a default value, and I’d like to set it to an empty dictionary instead of Nothing. How do I go about that?
In Java, I would simply do this:
Collections.<K,V>emptyMap()
How do I do the equivalent in VB.NET?
(I’m using .NET 3.5).
There is no way to specify an empty Dictionary as the default value for a parameter in VB.Net. VB.Net only supports values that can be encoded in MetaData and creating a new instance of a Dictionary is not one of them.
One option you do have though is to have an optional value which defaults to Nothing. In the case of Nothing create an empty dictionary. For instance.