开发者

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

This question already has answers here: Closed 11 years ago.

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):

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜