怎么都是IntelliSense并且编译器在 VB.NET 中接受 If 3 = True Then ...
?即使有 Option Strict上。
它实际上是否将 boolean 值视为整数,或者这是怎么回事?
最佳答案
来自 MSDN,Boolean Data Type (Visual Basic) :
When Visual Basic converts numeric data type values to Boolean, 0 becomes False and all other values become True.
因此,除了 0 之外,任何转换为 boolean 值的数字都会计算为 True
。
关于VB.NET 将 True/False 视为整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4759431/