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

On Next Page : Ansh Kalra 103171831 Page 1 of 1

This document provides a reference sheet on C# programming concepts including data types, literals, variables, operators, control flow statements, methods, classes, structs, enums, and arrays. It defines basic data types like integers, floating point numbers, booleans, strings and characters. It also covers common statements for assignments, method calls, and conditionals. The document describes how to declare and call methods, create custom types like classes, structs and enums, and how to work with arrays and collections. It provides an overview of programs, modules, input/output operations and comments.

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 DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views2 pages

On Next Page : Ansh Kalra 103171831 Page 1 of 1

This document provides a reference sheet on C# programming concepts including data types, literals, variables, operators, control flow statements, methods, classes, structs, enums, and arrays. It defines basic data types like integers, floating point numbers, booleans, strings and characters. It also covers common statements for assignments, method calls, and conditionals. The document describes how to declare and call methods, create custom types like classes, structs and enums, and how to work with arrays and collections. It provides an overview of programs, modules, input/output operations and comments.

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 DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

lOMoARcPSD|7961493

On next Page 

Ansh Kalra 103171831 Page 1 of 1


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) Text = “Good to see you”
Concatenation (joining strings)
Floating Point Numbers String Test= “Good” + “work”;
Float, Double (eg: 4, 5.5) Comparison
Ansh == Ansh
Strings and Characters
String, Char (eg: ”Hello”, ‘A')
Construction from other types:
y = Y.ToString ();
Boolean
Boolean (eg: True, False)

Simple Programming Statements


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

Declaring Methods
Declare a method with parameters: Boolean Operators and Other Statements
public int AddTwoNumbers(int number1, int Comparison: equal, less, larger, not equal, less eq
number2){} =, <, >, <>, <=, >=
Declare a method that returns data: Boolean: And, Or and Not
public int AddTwoNumbers(int number1, int && || !
number2) Skip an iteration of a loop
{return number1 + number2;} Continue;
Pass by reference: End a loop early
arg = 4;
Break;
squareRef(ref arg);
Console.WriteLine(arg); End a method:
Return;
Custom Types
Classes Arrays
public class Messages Declaration
{ Int [ ] numbers;
}
Access
Number[0]=11
Enumerations
enum Genre {rock, pop, jazz, country}; Loop with index i
Structs For(i=0;i<3;i++){number[i]=i;}
For each loop
struct Books{ public string title; foreach (int items in a_array){}
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);}

Ansh Kalra 103171831 Page 1 of 1

You might also like