Sie sind auf Seite 1von 1

C# Programming Reference Sheet

Built In Data Types & Literals Working with Strings


Integers Assignment (giving a string a value)
int year = 2018; String = “ThisIsAString”;
Floating Point Numbers Concatenation (joining strings)
float cost = 13.56; String Sntnce = string + “and it is great”;
Strings and Characters Comparison
string example = “This is an example”; Bool areEqual = String.Equals(String1,
Boolean String2, stringComparison.Ordinal);
Bool choice = true; Construction from other types:
String(sbyte* value, int value);

Simple Programming Statements Structured Programming Statements


Constant declaration If statement
Const int month = 3; If(IsTrue) {ThenDoThis()};
Variable declaration Case statement
Int I; Switch(c) {case var.1: DoThis break;
Assignment case var.2: DoOtherThing break;}
Int I = 100; While loop
Method call While (Var < 4) {DoThing(); Var++;}
calledMethod(); Repeat loop
Sequence of statements - grouped Do {Action} while(Number <5);(PostTest)
Group list by list.string; For loop: foreach (var number in array) {do};

Declaring Methods Boolean Operators and Other Statements


Declare a method with parameters: Comparison: equal, less, larger, not equal, less eq
==, <, >, !=, <=
Declare a method that returns data: Boolean: And, Or and Not
Int method(int i){return int} & (Escaping &&), | (||), ~
Pass by reference: Skip an iteration of a loop
Public class sampleReferencable {} Continue;
End a loop early
Break;
End a method:
Return;

Custom Types Arrays


Classes Declaration
Public/private class name {} DataType[] arrayName = {1,2,3,4} //Any size
Enumerations Access
Enum <name> {}; i = arrayName[3];
Structs Loop with index i
Public struct name {variable} For (I = 0; I < 10; I++) {arrayName.i=i+1)
For each loop
Foreach (int n in arrayName) {int i = n;
Console.writeline(i)
}

Programs and Modules Other Things


Creating a program Reading from Terminal
namespace _ProgramName Console.readline()
Writing to Terminal
Using a class from a library Console.writeLine(“I like bananas”)
Using System.collections.generic; Comments
//This is a comment

Your Name Your ID 1234567 Page 1 of 1

Das könnte Ihnen auch gefallen