O'Reilly logo

Programming Visual Basic 2008 by Tim Patrick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Data in .NET

All data types in .NET are implemented as classes within the System namespace. One such data type is System.Byte, which implements an 8-bit integer value, just like we discussed earlier. It holds integer values from 0 to 255. These values are always stored using 8 bits of binary data, but they magically appear in decimal form whenever you ask them to be presented.

The .NET Framework includes 15 core interpretive data types: 8 for integers, 3 for decimal numbers, 2 for character data, a combined data type for dates and times, and a Boolean data type.

Integer Data Types

Based on the number of available data types (8 out of the 15 core types), you would think that most programmers worked with integers all day long—and you'd be right. Whether it's actual user data or loop counters or status codes or the storage method for enumerated data types, integers show up everywhere in .NET code.

The range of values for an integer data type depends directly on the number of binary digits managed by that data type; the more digits, the bigger the range. Also, half of the integer data types store both positive and negative values (called "signed" integers), whereas the other half support only positive numbers ("unsigned"). Table 6-1 lists the eight integer data types included with .NET, and their associated ranges.

Table 6-1. Integer data types in .NET

.NET data type

Bits

Style

Range of values

System.Byte

8

Unsigned

0 to 255

System.SByte

8

Signed

-128 to 127

System.Int16

16

Signed

-32,768 to 32,767

System.UInt16 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required