IV: VB.NET Data Types


IV: VB.NET Data Types

The following table lists the data types that are available in VB.NET, listed alongside their Common Language Runtime (CLR) base type.

VB DATA TYPE NAME

CAN HOLD

SIZE IN MEMORY

CORRESPONDING CLR TYPE

Boolean

True or False

2 bytes

System.Boolean

Byte

0 to 255

1 byte

System.Byte

Char

One single character

2 bytes

System.Char

Date

January 1, 0001 00:00:00 through to December 31, 9999 11:59:59 PM

8 bytes

System.DateTime

Decimal

0 through to +/- 79,228,162,514,264,337, 593,543,950,335 with no decimal point; 0 through +/-7.9228162514264337593543950335 (with 28 places to the right of the decimal point)

16 bytes

System.Decimal

Double (double-precision floating-point)

-1.79769313486231570E+308 through to -4.94065645841246544E-324 fornegative values; 4.94065645841246544E-324 through to 1.79769313486231570E+308 for positive values

8 bytes

System.Double

Integer

-2,147,483,648 through to 2,147,483,647

4 bytes

System.Int32

Long (long integer)

9,223,372,036,854,775,807 -9,223,372,036,854,775,808 through to

8 bytes

System.Int64

Object

Any type can be stored in an Object variable

4 bytes

System.Object (class)

Short

-32,768 through to 32,767

2 bytes

System.Int16

Single (single-precision floating-point)

-3.4028235E+38 through to -1.401298E-45for negative values; 1.401298E-45 through 3.4028235E+38 for positive values

4 bytes

System.Single

String

0 to approximately 2 billion Unicode characters

Depends on platform

System.String (class)

User-Defined Types

Each member of the structure is determined by its data type

Depends on platform

System.ValueType (inherits from)

In the .NET world, you officially have two different types : value types and reference types. Value types simply contain core values and are stored on the application stack. Sample value types include Boolean, Integer, and Date.

Reference types are stored on the runtime heap, pointing to a particular object in memory. All objects derived from classes are reference types, including the String type, all arrays, forms, and so on.

In the many applications, this behind-the-scenes difference will have no or little impact on our programming. With powerful, highly requested applications, however, take the following two details into account:

  • All reference types are handled by the .NET Framework garbage collection process. This means that unused objects are marked for deletion and destroyed, say, every few minutes. At busy times, this can result in a lot of objects just consuming memory, waiting to be destroyed . So, where possible, use the more efficient value types.

  • Strings are more efficiently concatenated using the StringBuilder class. Using the simple & concatenation command can result in wasted memory strings that require garbage collection.




The Ultimate VB .NET and ASP.NET Code Book
The Ultimate VB .NET and ASP.NET Code Book
ISBN: 1590591062
EAN: 2147483647
Year: 2003
Pages: 76
Authors: Karl Moore

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net