Skip to content

C# practice

Practice C# online: 10 exercises and a playground

Your C# is compiled by Roslyn — the same compiler behind Visual Studio — and run by Microsoft's own Mono WebAssembly runtime, both loaded into your browser tab, so the errors you see are the real compiler's own. Console.WriteLine, string interpolation, List<T>, Dictionary<TKey,TValue> and LINQ all work exactly as they do locally, with one honest limit: there is no real filesystem or network from inside a program.

checked exercises
10
graded problems
0
lessons
0
cheat sheet (coming)
0

C# practice exercises

How the path works →

In order, each one introducing a single new idea. Press Run to check your answer; hints open one at a time.

  1. Coat Check Claim TicketDeclaring typed variables and printing their values with string interpolation
  2. Spelling Test Pass CheckerBranching with if/else based on a comparison
  3. Ferris Wheel Car NumberingRepeating a block a fixed number of times with a for loop
  4. Vending Machine RestockRepeating a block with a while loop until a condition becomes false
  5. Airport Security Line StatusReading a line from the console and parsing it into a number
  6. Chess Club Weekly AttendanceStoring multiple values in an array and looping over it safely by index
  7. Household Chore RotationUsing a List<string> to add items dynamically and read its Count
  8. Craft Fair Booth SalesUsing LINQ's Where and Sum to filter and total a list
  9. Town Hall Attendance by DistrictUsing a Dictionary<string,int> and ContainsKey to look up values safely by key
  10. Summer Camp Swim Test ResultsCombining lists, loops, and conditionals while avoiding integer-division truncation

Coding interview questions

Original questions with full model answers, for when the practice is going somewhere specific.

Questions people ask

Is this the real C# compiler?
Yes — Roslyn, the actual C# compiler, running in your browser tab. A syntax or type error is reported with the same kind of message and error code (like CS0029) you would see in Visual Studio or on the command line.
Do I need a class and a Main method for every exercise?
No. Top-level statements work here, so an exercise can be a plain sequence of lines with no boilerplate — the exercises use whichever shape best fits what they are teaching.
Can I read input with Console.ReadLine()?
Yes. Whatever you type into the input box beside the editor is what Console.ReadLine() returns, one line at a time, exactly as it would from a console application.
What comes after these exercises?
Beyond the 10 exercises, a blank playground is there for trying LINQ, collections or anything else from the C# standard library on your own.

Practise another language

The same kind of practice hub exists for Python, JavaScript, TypeScript, Java, C++, C, Go, PHP, Ruby, SQL, R and Bash & the Shell.