C# Data Types

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 4

Microsoft: DEV204x Programming with C#

Data Types
All applications store and manipulate data within the computer's memory. C#
supports two kinds of data types used to represent
real-world information. Value types are so-called because they contain the actual
value of the data they store. For example, you
might have an int type that stores the value 3. The literal value of 3 is stored in
the variable that you declare to hold it.
With the exception of DateTime and string, in the below table, the data types
listed are aliases for structs in .NET that represent the
data types in the Microsoft .NET Framework. Anyplace you can use int you can also
use System.Int32. We'll cover structs in module
four.
Reference types are also known as objects. Reference types are created from class
files, which you will cover in module five A
reference type stores a reference to the location in memory of the object. . If
you are familiar with C/C++ then you can think of a
reference to the memory location to be the same as a pointer. C# does not require
you to use pointers.
The following table shows the most commonly used value types.
Type

Description

Size (bytes)

.NET Type

Range

int

Whole numbers

System.Int32

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

long

Whole numbers (bigger


range)

System.Int64

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

float

Floating-point numbers
4

System.Single

+/-3.4 x 10^38

double

Double precision (more


accurate) floating-point
numbers

System.Double

+/-1.7 x 10^308

decimal

Monetary values

16

System.Decimal

28 significant figures

char

Single character

System.Char

N/A

bool

Boolean

System.Boolean

True or false

DateTime

Moments in time

System.DateTime

0:00:00 on 01/01/0001 to
23:59:59 on 12/31/9999
string

Sequence of characters

2 per character

System.String

N/A

© All Rights Reserved


© 2015 edX Inc.
EdX, Open edX, and the edX and Open edX logos are registered trademarks or
trademarks of edX Inc.

You might also like