0% found this document useful (0 votes)
42 views2 pages

C# Reference Sheet C# Reference Sheet

This document provides a reference sheet for C# programming concepts including data types, literals, variables, methods, classes, enums, structs, arrays, loops, conditionals, and other common programming elements. It lists built-in data types like integers, floating point numbers, strings, booleans, and custom types like classes, enumerations, and structures. It also describes simple and structured programming statements for flow control, iteration, and returning values from methods.

Uploaded by

Ansh Kalra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

C# Reference Sheet C# Reference Sheet

This document provides a reference sheet for C# programming concepts including data types, literals, variables, methods, classes, enums, structs, arrays, loops, conditionals, and other common programming elements. It lists built-in data types like integers, floating point numbers, strings, booleans, and custom types like classes, enumerations, and structures. It also describes simple and structured programming statements for flow control, iteration, and returning values from methods.

Uploaded by

Ansh Kalra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

lOMoARcPSD|7961493

C# Reference Sheet

Object-Oriented Programming (Swinburne University of Technology)

StuDocu is not sponsored or endorsed by any college or university


Downloaded by Ansh Kalra ([email protected])
lOMoARcPSD|7961493

C# Programming Reference Sheet


Built In Data Types & Literals Working with Strings
Integers
Assignment (giving a string a value)
Int, uint, long, ulong (eg: 7,10,21,22) Test = “Hello World”
Floating Point Numbers Concatenation (joining strings)
Float, Double (eg: 4, 5.5) String Test= “hello” + “world”;
Comparison
Strings and Characters bla == bla
String, Char (eg: 'World', 'I') Construction from other types:
x = X.ToString ();
Boolean
Boolean (eg: True, False)

Simple Programming Statements Structured Programming Statements


Constant declaration
If statement
private const int days = 12;
If (Correct)then {} else …
Variable declaration
Int I = 0; Case statement
Switch (x) {case1: Console.Writeln
Assignment
(“Case1”); break; case 2: ….; break; }
a=1;
Method call <Access Specifier> <Return Type> While loop
<Method Name>(Parameter List) {Method Body} while (this is correct) do {…; i++}
Repeat loop
Sequence of statements - grouped do{x+1; x++;} while (x<5);
{} For loop

Declaring Methods Boolean Operators and Other Statements


Declare a method with parameters: Comparison: equal, less, larger, not equal, less eq
public int AddTwoNumbers(int number1, int =, <, >, <>, <=, >=
number2){} Boolean: And, Or and Not
Declare a method that returns data: && || !
public int AddTwoNumbers(int number1, int Skip an iteration of a loop
number2) Continue;
{return number1 + number2;} End a loop early
Pass by reference: Break;
arg = 4; End a method:
squareRef(ref arg);
Console.WriteLine(arg);
Return;

Custom Types Arrays


Classes Declaration
public class Students Int [ ] numbers;
{ Access
} Number[0]=11
Loop with index i
Enumerations For(i=0;i<3;i++){number[i]=i;}
enum Genre {rock, pop, jazz, country};
For each loop
Structs foreach (int radius in radii){}
struct Books{ public string title; public string author;}

Programs and Modules Other Things


Creating a program Reading from Terminal
class MainClass Console.Readline()
{ Writing to Terminal
public static void Main() Console.Writeline()
{
} Comments
Using a class from a library //Single line Comment
Using SwinGameSDK;
public void Draw ()
{
SwinGame.FillRectangle (_color, _x, _y,
_width, _height);}

Amritpal Singh Thind 101021730 Page 1 of 1

Downloaded by Ansh Kalra ([email protected])

You might also like