What is a Variable? & Data Types and Value Ranges


What is a Variable?

A variable is a memory/data information field that can take/transfer different values every time the program runs, and these fields are called variables.

Variables should comply with naming conventions and should be named in a way that makes associations for the user about the value/data they store. Click here to see the naming conventions.

If we need to give examples of variables;
They should be similar to AdSoy, AdSoyad, adSoyad, Ad_Soyad.

Variables are one of the building blocks in coding and developing a program; you cannot create a program without variables, and even if you do, it will not be as efficient or advanced as a program using variables.


Data Types

Integer (Int): Data type that holds integer numbers
Float: Data type that holds decimal numbers
Bool: Data type that takes the value True or False 
String: Data type made up of chars and can store words
Char: Data type that can hold only 1 letter

Value Ranges

Data types that hold integer numbers

TypeBitValue Range
byte80 to 255
sbyte8-128 to 127
short16-32,768 to 32,767
ushort160 to 65,535
int32-2,147,483,648 to 2,147,483,647
uint320 to 4,294,967,295
long64-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
ulong640 to 18,446,744,073,709,551,615

Types that hold decimal numbers

TypeBitValue Range
float321.5E-45 to 3.4E+38
double645E-324 to 1.7E+308
decimal1281E-28 to 7.9E+28

Textual types

TypeBitValue Range
char16One character
string20+(n/2)*4Can store character chains of desired length

Logical types

TypeBitValue Range
bool16true-false