Show Menu
Cheatography

Data Types

Name
Example
bool
bool flag = True
char
char c = '#'
string
string text = "cake is great"
int
int x = 29
double
double a = 3.14

Casting and Type Conver­sions

From
To
Use
double
int
(int)x
string
int
int.Pa­rse(x)
x means the original variable that you are converting.
example:
a = (int)7.2

Arrays

Initia­liz­ation
datatype[] name = new dataty­pe[­size]

example:
int[] arr = new int[2]

datatype[] name = {value1, value2, ...}

example:
string[] names = {"Bo­b", "­Jac­k", ...}


Multi-­Dim­ens­ional Arrays
dataty­pe[,] name = new dataty­pe[­size0, size1]

example:
int[,] arr = new int[2, 4]
 

Flow Control

Branching
Looping
if (condi­tion) {
    (statments)
}
while (condi­tion) {
    (statments)
}
elseif (condi­tion) {
    (statments)
}
do  {
    (statments)
} while (condi­tion)
else  {
    (statments)
}
for (initi­ali­zation; condition; step)  {
    (statments)
}

Boolean Logic Operators

Operator
Meaning
&&
and
||
or
!
not
 

Console I/O

Line Input
Consol­e.R­ead­Line()
Line Output
Consol­e.W­rit­eLine()
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          C++ Pointers cookbook Cheat Sheet
          Modern C++ 17 Standard Library Features Cheat Sheet
          C# CheatSheet Cheat Sheet