C# Cheat Sheet

A cheat sheet in English by Kimyo
10,184 views 2,498 downloads 28 Jul 2016 History
3.7 avg · 1 rating

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()

Badges

Nice Cheat Sheet Good Cheat Sheet Downloaded from Unusual Locations × 3

Comments

No comments yet.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.