← Back to Tutorials Chapter 10

Practice & Resources

Practical Examples

// 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

  1. Write a program that counts vowels in a string
  2. Create a class BankAccount with Deposit and Withdraw methods
  3. Read a CSV file and calculate the average of a column
  4. Build a simple to-do list app using List
  5. Implement a generic method that swaps two values

Quiz Questions

4-Week Study Plan

Resources

C# practice roadmap

Practice Task

Write a C# program that applies the concepts covered in this chapter. Experiment with different inputs and test your understanding.