开发者

VB.NET Dim mySingle As Single = "" runtime error

the compilation of 开发者_Go百科 Dim mySingle As Single = "" is ok, but at runtime it throw an exception: Conversion from string "" to type 'Single' is not valid.

How could it be possible?

Thanks


Strings aren't Singles.

It compiles because you don't have Option Strict.
Without Option Strict On (either at the top of the file or preferably in project properties), all type-checking happens at runtime; there is no compile time type-safety.

You should ALWAYS use Option Strict.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜