A constant expression is expressions whose value can be fully evaluated at compile time. The type of a constant expression can be one of the following: Byte
, Short
, Integer
, Long
, Char
, Single
, Double
, Decimal
, Boolean
, String
, any enumeration type, or the null type. The following constructs are permitted in constant expressions:
Nothing
).+
, –
, BitNot
and Not
unary operators.+
, –
, *
, ^
, Mod
, /
, \
, &
, BitAnd
, BitOr
, BitXor
, And
, Or
, =
, <
, >
, <>
, <=
, and =>
binary operators, provided each operand is of a type listed above.Microsoft.VisualBasic.Strings.Chr
and Microsoft.VisualBasic.Strings.Asc
Constant expressions permit a constant expression of type Integer
to be implicitly converted to Byte
and Short
and a constant expression of type Double
to be implicitly converted to Single
, provided the value of the constant expression is within the range of the destination type. This is done regardless of whether permissive or strict semantics are being used.