Question

[Solved] C# to VB.NET: the **default** keyword? [duplicate]

Possible Duplicate:
Default value for generics

OK, so while translating some code from C# to VB.NET, I came across the default keyword, and I’m simply replacing it with nothing.

Is this the proper way to do it, or is there a better “translation” for that keyword?

Solution #1:

Yup, that’s absolutely fine. While Nothing is usually meant to mean the equivalent of C#’s null, it can be used with value types to, to mean “the default value of that type”.

Respondent: Jon Skeet
Solution #2:

“default” is used in the context of generics, especially when you do not know the type but still want to have an instance of the default value of the generic type. I am not very good at Visual Basic, but I can imagine there is an equivalent to do the same(?).

For an example of the usage of the default keyword in C#, see default Keyword in Generic Code (C# Programming Guide) (MSDN):

Respondent: Flawless
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy