C# Variables

Last modified: July 11, 2021

A variable is just a name given to a storage area, it has specific type, which determines the size and layout of the variable's memory.

Type Example
Integral sbyte, byte, short, ushort, int, uint, long, ulong
floating point double, float
decimal decimal
char Single character
string store text such as "I live in US"
boolean true or false
Nullable nullable data types

We create a variable like below

<data type> <variable name> = <value>;

Example how the variables create.

int totalNumberOfMonthsInAyear = 12; string nameOfCityinUSA = "New York"; bool isItHot = true; decimal amountOfMoneyInBank = 1232233.2332