974 B
974 B
Variables
int
for storing integer
int age = 21;
double
can store a decimal
double height = 300.5;
bool
can store boolean only true or false
bool alive = true;
char
for a single carachter
char symbole = '@';
String
don't forget the S in upper
String name = "Hello";
constants
immutable values wich are known at compile time and do not change for th life of the program
just add the const keyword
const double pi = 3.14;
Type casting
Converting a value to a different data type Very useful because user input will always be strings
double a = 3.14;
int b= Convert.ToInt32(a);
int c= 123;
double d= Convert.ToDouble(c);
int e= 321;
String d= Convert.ToString(e);
String g = "$";
char h = Convert.ToChar(g);
String i = "true";
bool j = Convert.ToBoolean(i);
GetType
Get the type of a variable
double a = 3.14;
Console.WriteLine(a.GetType())