// Add Two Numbers
int Add(int a, int b) => a + b;
// Reverse a String
string Reverse(string s) => new string(s.Reverse().ToArray());
// Check Palindrome
bool IsPalindrome(string s) => s == Reverse(s);
// FizzBuzz
for (int i = 1; i <= 100; i++) {
if (i % 15 == 0) Console.WriteLine("FizzBuzz");
else if (i % 3 == 0) Console.WriteLine("Fizz");
else if (i % 5 == 0) Console.WriteLine("Buzz");
else Console.WriteLine(i);
}
// Factorial
int Factorial(int n) => n <= 1 ? 1 : n * Factorial(n - 1);
Exercises
Write a program that counts vowels in a string
Create a class BankAccount with Deposit and Withdraw methods
Read a CSV file and calculate the average of a column
Build a simple to-do list app using List
Implement a generic method that swaps two values
Quiz Questions
What is the difference between ref and out parameters?
What is the purpose of the using statement?
What is the difference between abstract class and interface?
What does the var keyword do?
4-Week Study Plan
Basics, variables, control flow, arrays, methods
OOP, classes, inheritance, polymorphism
Exceptions, file I/O, LINQ, generics
Async, delegates, build a mini project
Resources
Microsoft C# Documentation (learn.microsoft.com/dotnet/csharp)
.NET Fiddle (dotnetfiddle.net) — online compiler
C# Yellow Book by Rob Miles
Practice Task
Write a C# program that applies the concepts covered in this chapter. Experiment with different inputs and test your understanding.