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
String
s aren't Single
s.
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
.
精彩评论