© Mikael Olsson 2018
Mikael OlssonC# 7 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-3817-2_3

3. Variables

Mikael Olsson1 
(1)
Hammarland, Länsi-Suomi, Finland
 

Variables are used for storing data in memory during program execution.

Data Types

Depending on what data you need to store, there are several different kinds of data types. The simple types in C# consist of four signed integer types and four unsigned, three floating-point types, as well as char and bool.

Data Type

Size (Bits)

Description

sbyte

short

int

long

8

16

32

64

Signed integers

byte

ushort

uint

ulong

8

16

32

64

Unsigned integers

float

double

decimal

32

64

128

Floating-point numbers

char

16

Unicode character

bool

4

Boolean value

Declaration

In C#, a variable must be declared ...

Get C# 7 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.