C# Data Types

The smallest piece of data that a computer can hold, is called a bit. A bit can only have one of two values, either 0 (off), or 1 (on). A bit can be referred to as binary data, as it only has two possible values.

Primary and Secondary Storage Measurements

Computers typically measure primary and secondary storage using the following table:

Storage Type (1 unit)Measurement
bit1 bit
byte8 bits
kilobyte1,024 bytes
megabyte1,024 kilobytes
gigabyte1,024 megabytes
terabyte1,024 gigabytes

This table can be extended further, to include even larger storage types. The bit is the foundation of all storage types. Larger storage types build off the smaller storage types. Larger data types are used to make it easier to conceptualize large measurements of bits. It’s easier to conceptualize 1 terabyte, as opposed to 8,000,000,000,000 bits.

Bytes can also be grouped into words. Modern computers typically use 4-byte, and 8-byte words, which are 32-bit (x86), and 64-bit (x64) systems, respectively.

Elementary Data Types

Name (System)Type (C#)Size
Booleanbool2 bytes
Bytebyte1 byte
Characterchar2 bytes
16-bit Integer*short | ushort2 bytes
32-bit Integer*int | uint4 bytes
64-bit Integer*long | ulong8 bytes
Decimaldecimal16 bytes
Single-precision floating point numberfloat4 bytes
Double-precision floating point numberdouble8 bytes
StringstringPlatform Dependent

*Integer values can also be unsigned, which removes the ability to store negative integers, and increases the storage for positive integers, i.e.:

Signed Short-32,768 to 32,767
Unsigned Short0 to 65,535

External References

For a complete, and up-to-date list, search Google for:

Leave a Reply