Cheatography
https://cheatography.com
Key syntax and concepts of C# and have a quick reference guide to the basics of C# programming.
This is a draft cheat sheet. It is a work in progress and is not finished yet.
1. Basic Structure
//'using' allows for easier access to types in a namespace.
using System;
//Namespaces organize code and prevent naming collisions.
namespace YourNamespace
{
class YourClass //A 'class' defines the blueprint of objects.
{
static void Main(string[] args) //'Main' is where the program starts execution.
{
Console.WriteLine("Hello, World!"); //Displays text in the console.
}
}
}
|
|
2. Data Types
|
whole numbers |
|
decimals |
|
single character |
|
text |
|
true/false |
Conditional Statements
if (age > 18) {
Console.WriteLine("Adult");
} else {
Console.WriteLine("Minor");
}
switch (grade) {
case "A":
Console.WriteLine("Excellent");
break;
default:
Console.WriteLine("Unknown grade");
break;
}
|
|
|
|