vb.netboolean

VB.NET treating True/False as Integer


How come both IntelliSense and the compiler accepts If 3 = True Then ... in VB.NET? Even with Option Strict on.

Does it in actuality treat Booleans as Integers, or what's the deal?


Solution

  • From 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.

    So, any number that is converted to boolean evaluates to True, apart from 0.