This documentation is archived and is not being maintained.

7.3 Primitive Types

Visual Studio .NET 2003

The primitive types are identified through keywords, which are aliases for predefined types in the System namespace. A primitive type is completely indistinguishable from the type it aliases: writing the reserved word Byte is exactly the same as writing System.Byte.

Because a primitive type aliases a regular type, every primitive type has members. For example, Integer has the members declared in System.Int32. Literals can be treated as instances of their corresponding types.

The primitive types differ from other structure types in that they permit certain additional operations:

  • Primitive types permit values to be created by writing literals. For example, 123I is a literal of type Integer.
  • It is possible to declare constants of the primitive types.
  • When the operands of an expression are all primitive type constants, it is possible for the compiler to evaluate the expression at compile time. Such an expression is known as a constant expression.

Visual Basic .NET defines the following primitive types:

  • The integral value types Byte (1-byte unsigned integer), Short (2-byte signed integer), Integer (4-byte signed integer), and Long (8-byte signed integer). These types map to System.Byte, System.Int16, System.Int32, and System.Int64, respectively. The default value of an integral type is equivalent to the literal 0.
  • The floating-point value types Single (4-byte floating point) and Double (8-byte floating point). These types map to System.Single and System.Double, respectively. The default value of a floating-point type is equivalent to the literal 0.
  • The Decimal type (16-byte decimal value), which maps to System.Decimal. The default value of decimal is equivalent to the literal 0D.
  • The Boolean value type, which represents a truth value, typically the result of a relational or logical operation. The literal is of type System.Boolean. The default value of the Boolean type is equivalent to the literal False.
  • The Date value type, which represents a date and/or a time and maps to System.DateTime. The default value of the Date type is equivalent to the literal # 01/01/0001 12:00:00AM #.
  • The Char value type, which represents a single Unicode character and maps to System.Char. The default value of the Char type is equivalent to the constant expression ChrW(0).
  • The String reference type, which represents a sequence of Unicode characters and maps to System.String. The default value of the String type is a null reference.
PrimitiveTypeName ::= NumericTypeName | Boolean | Date | Char | String
NumericTypeName ::= IntegralTypeName | FloatingPointTypeName | Decimal
IntegralTypeName ::= Byte | Short | Integer | Long
FloatingPointTypeName ::= Single | Double

See Also

7.1 Value Types and Reference Types | 7.6 Structures | 7.5 Classes | 7.7 Standard Modules | 7.8 Interfaces | 7.9 Arrays | 7.10 Delegates | 11.2 Constant Expressions | Data Type Summary (Visual Basic Language Reference) | Value Types and Reference Types (Visual Basic Language Concepts)

Show: