2.9. System Namespace
Every time you compile anything in Visual Basic, the compiler automatically references two assemblies: mscorlib.dll and Microsoft.VisualBasic.dll. These two components contain the System and Microsoft.VisualBasic namespaces, respectively (a small portion of the System namespace is also contained in System.dll).
The System namespace is the root namespace of primary types in .NET and contains the base data types used by all languages in the framework. When you declare a primitive data type in VB, it is actually mapped to a type defined in this namespace. Table 2-1 provides a list of the types in System and how they relate to Visual Basic.
System | Visual Basic | Description |
Byte | Byte | 8-bit unsigned integer |
Int16 | Short | 16-bit signed integer |
Int32 | Integer | 32-bit signed integer |
Int64 | Long | 64-bit signed integer |
Single | Single | 32-bit floating point |
Double | Double | 64-bit floating point |
Boolean | Boolean | True or False |
Char | Char | Unicode character |
Decimal | Decimal | 96-bit decimal value |
String | String | Unicode character string |
Object | Object | Base of all objects |
How you declare variables in your code doesn't matter. Each represents a functional equivalent:
Dim x As System.Int32 'Is the same as Dim x As Integer
If you examine Table 2-1 you will see that the Byte is the only unsigned data type supported by VB. All other integer types are signed. The Common Language Specification doesn't support ...
Get Object-Oriented Programming with Visual Basic .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.