Show Menu
Cheatography

Year 11 SDD C# Cheat Sheet by

Data Types

bool
Boolean Value
int
Integer (32 Bit)
string
String Value
float
Integer with Decimal (32 Bit)
double
Integer with Decimal (64 Bit)
Declaring Variables:

Data­Type variab­leName = value;

Exam­ples:
string mySchool = "­Pacific Hills Christian School­";
int myPostcode = 2158;
bool gameOver = false;

Type Conversion Methods

Conver­t.T­oInt32
Conver­t.T­oDouble
Conver­t.T­oString
Exam­ple:

player­guess = Conver­t.T­oIn­t32­(Co­nso­le.R­ea­dLi­ne());

Arrays

int[] array = new int[] {1, 2, 3}
int[] array = {1, 2, 3}
var array = new int[] {1, 2, 3}
int[] array = new int[3]
Exam­ples:

Decl­ari­ng:
string[] PHCS = {"Quarry Rd", "­Dur­al"};

Assi­gning
PHCS[0] = "9-14 Quarry Rd"

Acce­ssing
Consol­e.W­rit­eLi­ne(­PHC­S[1])
 

Statements

if-else
if (true) {...}
else if (true) {...}
else {...}
switch
switch (var) {
case 1: break;
default: break; }
for
for (int i =1; i < 5; i++) {...}
foreach-in
foreach (int item in array) {...}
while
while (true) {...}
do... while
do {...} while (true);
try-ca­tch­-fi­nally
try {...}
catch (Exception e) {...}
catch {...}
finally {...}

Logical Operators

and
&&
or
||
not
!

Arithmetic Operators

+
Add Numbers
-
Subtract Numbers
*
Multiply Numbers
/
Divide Numbers
%
Compute remainder of division of numbers
++
Increase integer value by 1
--
Decreases integer value by 1

Comparison Operators

<
Less than
>
Greater than
<=
Less than or equal to
=>
Greater than or equal to
==
Equal to
!=
Not Equal to
   

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi
 

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# & Unity MonoBehaviour Cheat Sheet
          Numeric Formats Cheat Sheet