C# Coding Reference


Type Conversion Chart
Collections Conversion Chart
Loop Syntax

For
for (int x=0; x < myArr.Length; x++) {
 Console.WriteLine(myArr[x]);
}

For Each
foreach (int a in myArr) {
 total += a;
}

While
while (x < 10) {
 Console.WriteLine("still");
 x++;
}

Do While
do {
 Console.WriteLine("still");
 x++;
} while (x < 10);

Linq Commands

Must include "using System.Linq;" when doing any Linq commands.

Declaration Syntax

Functions:
public static bool myFunction(int a, int b) {
 return (a == b);
}

Lists:
List<int> myList = new List<int>();
myList.Add(1);

Arrays:
string[] myArr = new string[] {"cat, "dog", "pig"}
myArr[2] = "hamster";

Visual Studio Shortcuts
Reference
Libraries/Extensions:
Null Operators:
string padleft