Show Menu

C# Cheat Sheet by

c-     programming

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.P­ars­e(x)
x means the original variable that you are converting.
example: a = (int)7.2

Arrays

Init­ial­iza­tion
datat­ype[] name = new dataty­pe[­size]
example: int[] arr = new int[2]
datat­ype[] name = {value1, value2, ...}
example: string[] names = {"Bo­b", "­Jac­k", ...}

Mult­i-D­ime­nsional Arrays
datat­ype[,] 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
Conso­le.R­ea­dLi­ne()
Line Output
Conso­le.W­ri­teL­ine()

Download the C# Cheat Sheet

1 Page
//media.cheatography.com/storage/thumb/kimyo_c.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

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

          Numeric Formats Cheat Sheet
          RhinoMocks Cheat Sheet