Introduction to C#
Introduction to C#
Sarbendra sigdel
Literals in C# x
s.sigdel
Operators in C# x
Arithmetic Operators
+ - * / %
Relational Operators
Logical Operators
&& || !
s.sigdel
Operators in C# x
Assignment Operators
= += -= *= /= %=
Bitwise Operators
Unary Operators
+ - ++ -- !
s.sigdel
Operators in C# x
Ternary Operator
?:
Null-Coalescing Operators
?? ??=
Type Operators
s.sigdel
Operators in C# x
[] ^
s.sigdel
Conditional statements in C# x
else
Console.WriteLine("Failed!");
s.sigdel
Conditional statements in C# x
Switch
switch (expression) {
case value1:
// Code block
break;
case value2:
// Code block
break;
default:
// Default code block
break;
}
s.sigdel
Loops in C# x
For Loop :
Best for known iterations
Output:
12345
s.sigdel
Loops in C# x
While Loop :
Runs while a condition is true
int i = 1;
while (i <= 5)
{
Console.WriteLine(i);
i++;
}
Output:
12345
s.sigdel
Loops in C# x
Do While Loop :
Runs at least once, then checks the condition
int i = 1;
do
{
Console.WriteLine(i);
i++;
} while (i <= 5);
Output:
12345
s.sigdel
Loops in C# x
Foreach Loop :
The foreach loop is used to iterate through each element in a
collection (like an array or list)
Output:
Apple Banana Cherry Mango
s.sigdel
Why C# x
Game Development
Cross-Platform
Beginner-Friendly
High Performance
s.sigdel