PYnative

Python Programming

  • Learn Python ▼
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises ▼
    • Python Exercises
    • C++ Exercises
    • C Programming Exercises
    • Java Exercises
    • C# Exercises
  • Quizzes
  • Code Editor ▼
    • Online Python Code Editor
    • Online C Compiler
    • Online C++ Compiler
    • Online Java Compiler
    • Online C# Compiler
Home » C# Exercises

Practice C# Exercises & Challenges with Solutions [620+ Coding Questions]

Free Coding Exercises for C# Developers. Practice C# with 22 topic-wise exercises with over 620+ hands-on coding questions to practice covering everything from C# basics to advanced.

What is included in these C# Exercises?

  • All exercises are tested on the latest version of C#/.NET.
  • Each exercise contains a set of 20-40 coding questions or challenges, focusing on specific C# topics to give you targeted practice
  • Hints and solutions are provided for every question. This enables you to immediately check your code and learn from any mistakes
  • Practice each Exercise using our Online C# Compiler

Whether you're a beginner taking your first steps or an experienced developer looking to refine your skills, these exercises are designed to be beneficial.

Below is the list of exercises. Select the exercise you want to solve. All the Best.

C# Exercises for Beginners

Total Exercises: 58

This C# beginner's exercise helps you quickly learn and practice basic skills by solving coding questions and challenges on below topics. You'll write small programs that reinforce syntax, console input/output, and basic problem-solving before moving on to more advanced concepts. Each question comes with a hint and a full solution so you can check your understanding right away.

Topics: C# Basics, Variables, Data Types, Operators

C# Loops Exercises

Total Exercises: 31

This exercise contains coding challenges to solve using if-else conditions, for loops, while loops, and do-while loops. You'll practice nested loops, loop control statements like break and continue, and common patterns such as number series, pattern printing, and iterative searches. These questions build the foundation for writing efficient, readable control flow in C#.

Topics: Control flow statements, for loop, while loop, do-while loop

C# Array Exercises

Total Exercises: 30

Practice creating, manipulating, and iterating over single and multi-dimensional arrays in C#. Solve questions on array traversal, searching, sorting, resizing, and jagged arrays. These exercises help you get comfortable with built-in array methods and common array-based algorithms.

Topics: Arrays, Multi-dimensional Arrays, Array Methods

C# String Exercises

Total Exercises: 30

Practice string manipulation, formatting, and commonly used string methods in C#. Work through questions on searching, splitting, joining, trimming, and comparing strings, plus interpolation and formatting techniques. You'll also practice building small text-processing programs using StringBuilder for efficient string manipulation.

Topics: Strings, String Methods, String Formatting

C# Structs, Records & Enums Exercises

Total Exercises: 25

Practice creating and using structs, records, and enums to model data in C#. Solve questions that compare value types with reference types, use record types for immutable data models, and apply enums to represent fixed sets of related constants. These exercises help you choose the right type for the right modeling problem.

Topics: Structs, Records, Enums

C# OOP Exercises

Total Exercises: 40

Practice object-oriented programming concepts such as classes, inheritance, polymorphism, encapsulation, and abstraction. Build class hierarchies, override methods, work with interfaces and abstract classes, and design constructors that model real-world entities. These exercises strengthen your ability to design clean, reusable, object-oriented C# code.

Topics: Classes, Inheritance, Polymorphism, Encapsulation, Abstraction

C# Collections Exercises

Total Exercises: 30

Practice working with generic and non-generic collections in C#. Solve questions covering Queue<T>, Stack<T>, HashSet<T>, and LinkedList<T>, including when to choose each based on ordering, uniqueness, and performance needs. You'll also compare collection behavior against plain arrays and lists.

Topics: Collections, Queue, Stack, HashSet

C# List Exercises

Total Exercises: 35

Practice creating, modifying, sorting, and searching [List<T>] collections in C#. Work through questions on adding, removing, and updating elements, custom sorting with comparers, and filtering with LINQ-style queries. These exercises build practical fluency with the collection type you'll use most often in everyday C# development.

Topics: List<T>, Sorting, Searching

C# Dictionary Exercises

Total Exercises: 30

Practice creating and manipulating Dictionary<TKey, TValue> collections in C#. Solve questions on adding, updating, and removing key-value pairs, checking for key existence, and iterating over entries. You'll also practice using dictionaries to solve common problems like counting occurrences and grouping data.

Topics: Dictionary<TKey, TValue>, Key-Value Pairs

C# Generics Exercises

Total Exercises: 20

Practice writing generic classes, methods, and interfaces for reusable, type-safe code. Solve questions on applying generic constraints, building generic data structures, and writing methods that work across multiple types without sacrificing type safety. These exercises help you write more flexible and maintainable C# code.

Topics: Generics, Generic Methods, Generic Constraints

C# LINQ Exercises

Total Exercises: 40

Practice querying collections using LINQ query syntax and method syntax. Solve questions on filtering, projecting, grouping, joining, and aggregating data with methods like Where, Select, GroupBy, and OrderBy. These exercises help you write concise, expressive data queries instead of manual loops.

Topics: LINQ, Query Syntax, Method Syntax

C# Lambda Expressions Exercises

Total Exercises: 25

Practice writing lambda expressions and using them with delegates and LINQ. Solve questions that use Func, Action, and Predicate delegates, and apply lambdas to filter, transform, and process collections. These exercises build comfort with the functional-style syntax used throughout modern C#.

Topics: Lambda Expressions, Func, Action, Predicate

C# Delegates & Events Exercises

Total Exercises: 20

Practice creating and using delegates, multicast delegates, and events in C#. Solve questions on defining custom delegate types, subscribing and unsubscribing event handlers, and building simple publisher-subscriber style programs. These exercises help you understand how C# handles callbacks and event-driven behavior.

Topics: Delegates, Multicast Delegates, Events

C# Extension Methods Exercises

Total Exercises: 20

Practice writing extension methods to add new functionality to existing types without modifying them. Solve questions that extend built-in types like string, int, and collection types with your own reusable helper methods. These exercises show you how to write cleaner, more fluent APIs on top of existing classes.

Topics: Extension Methods

C# Exception Handling Exercises

Total Exercises: 20

Practice handling runtime errors using try-catch-finally blocks and custom exceptions. Solve questions on catching specific exception types, using multiple catch blocks, and creating your own exception classes for domain-specific errors. These exercises help you write programs that fail gracefully instead of crashing.

Topics: try-catch, Custom Exceptions, finally

C# File Handling Exercises

Total Exercises: 30

Practice reading from and writing to files using C# file I/O classes. Solve questions on reading text files line by line, writing and appending content, and working with file and directory information. These exercises give you hands-on experience with everyday file-handling tasks.

Topics: File I/O, StreamReader, StreamWriter

C# Date and Time Exercises

Total Exercises: 25

Practice working with DateTime, TimeSpan, and date/time formatting in C#. Solve questions on parsing and formatting dates, calculating differences between dates, and performing date arithmetic. These exercises help you handle the date and time logic that comes up constantly in real applications.

Topics: DateTime, TimeSpan

C# Regex Exercises

Total Exercises: 30

Practice pattern matching and text extraction using regular expressions in C#. Solve questions on validating input formats, extracting matches and groups, and replacing text using the Regex class. These exercises build practical skills for parsing and validating real-world text data.

Topics: Regex, Pattern Matching

C# Pattern Matching Exercises

Total Exercises: 20

Practice using pattern matching features such as switch expressions and type patterns. Solve questions on type checks with the is operator, property patterns, and concise switch expressions that replace verbose if-else chains. These exercises help you write more modern, readable conditional logic in C#.

Topics: Pattern Matching, Switch Expressions

C# Iterators & Yield Exercises

Total Exercises: 25

Practice creating custom iterators using the yield keyword. Solve questions on building custom enumerable sequences, lazy evaluation, and implementing IEnumerable for your own types. These exercises help you understand how iteration works under the hood in C#.

Topics: Iterators, yield return

C# Indexers & Operator Overloading Exercises

Total Exercises: 15

Practice creating custom indexers and overloading operators for user-defined types. Solve questions on defining this[] indexers for custom classes and overloading operators like +, ==, and < to give your types natural, intuitive syntax. These exercises help you design classes that feel like built-in C# types.

Topics: Indexers, Operator Overloading

C# Random Data Generation Exercises

Total Exercises: 20

Practice generating random numbers and data using the Random class and related APIs. Solve questions on generating random integers, doubles, and strings within given ranges, shuffling collections, and creating unique identifiers with Guid. These exercises are useful for simulations, testing, and sample data generation.

Topics: Random class, Guid

C# Random Data Generation Exercises: 20 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Pattern Matching Exercises: 20 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Indexers and Operator Overloading Exercises: 15 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Iterators and Yield Exercises: 25 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# DateTime Exercises: 25 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Regex Exercises: 30 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# File Handling Exercises: 30 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Exception Handling Exercises: 20 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Extension Methods Exercises: 20 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Delegates and Events Exercises: 20 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Lambda Expressions Exercises: 25 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# LINQ Exercises: 40 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# List Exercises: 35 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Collections Exercises: 30 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Dictionary Exercises: 30 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Generics Exercises: 20 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# OOP Exercises: 40 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Structs, Records, and Enums Exercises: 25+ Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

Online C# Compiler

Updated on: July 14, 2026 | Leave a Comment

Filed Under: C# Exercises

C# String Exercises: 30 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Array Exercises: 30 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

C# Loops Exercises: 30 Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

Basic C# Exercises for Beginners: 50+ Coding Problems with Solutions

Updated on: July 15, 2026 | Leave a Comment

Filed Under: C# Exercises

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises
  • Java Exercises
  • C# Exercises

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2026 pynative.com