C# to VB.NET: the **default** keyword? [duplicate]
Possible Duplicate:
Default value for gene开发者_开发技巧rics
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?
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".
"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):
精彩评论