O'Reilly logo

Microsoft® Visual C#® 2008 Step by Step by John Sharp

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

Working with Primitive Data Types

C# has a number of built-in types called primitive data types. The following table lists the most commonly used primitive data types in C# and the range of values that you can store in each.

Data type

Description

Size (bits)

Range [a]

Sample usage

int

Whole numbers

32

–231 through 231 – 1

int count;
count = 42;

long

Whole numbers (bigger range)

64

–263 through 263 – 1

long wait;
wait = 42L;

float

Floating-point numbers

32

±1.5 x 1045 through ±3.4 x 1038

float away;
away = 0.42F;

double

Double-precision (more accurate) floating-point numbers

64

±5.0 x 10-324 through ±1.7 x 10308

double trouble;
trouble = 0.42;

decimal

Monetary values

128

28 significant figures

decimal coin;
coin = 0.42M;

string

Sequence of characters

16 bits per character

Not applicable ...

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