C# Playground

Write and run real C# 14 in your browser, with IntelliSense, even offline.

Runs in your browser — nothing is uploaded

  

Real C#, in the page

This playground runs Roslyn, the official C# compiler, on the .NET 10 runtime compiled to WebAssembly. Your program is compiled into an assembly and executed right here, so the language is exactly the C# you write everywhere else: top-level statements or a classic Main, async Main with await, records and with-expressions, pattern matching with switch expressions and list patterns, LINQ query and method syntax, generics with constraints, collection expressions with spreads, primary constructors, and C# 14 extension members.

Each run loads a fresh copy of your program, so static fields start over every time. Output appears as it is written, and Stop ends even a program that loops forever.

Errors and completion as you type

The compiler checks your code continuously. Errors are underlined in red and warnings in yellow — an unused variable, a possible null dereference — with the compiler's own message and code, such as CS0029 for a type mismatch. If you press Run with errors, the output lists them in the familiar file(line,column) format and nothing runs.

Completion comes from Roslyn's own completion service, the engine behind IntelliSense. Type a dot after a string and you get its methods along with LINQ's, each with its signature and documentation; your own classes, records and methods appear too.

Built for practice

Use it to try an idea, check how a LINQ operator behaves, explore a new language feature or practise for an interview without installing an SDK. The Examples menu has short programs for many modern features, and every one runs as a starting point for your own. When an uncaught exception ends a program, you see its type, message and a stack trace pointing at the exact lines of your code.

How to use

  1. Type or paste C#, or pick an example.
  2. Watch errors and warnings underline as you type; use Ctrl+Space for completion.
  3. Press Run (Ctrl/⌘+Enter in the editor) to compile and see the output.

FAQ

Is this the real C# compiler?

Yes. It is Roslyn, the same compiler Visual Studio and the dotnet command use, running on Microsoft's .NET 10 runtime compiled to WebAssembly. Programs compile to a real assembly and run against the .NET base class library: LINQ, collections, async/await, records, generics, regular expressions, System.Text.Json, LINQ to XML and hashing behave as they do on your machine. What a browser tab can't do — start threads or processes, block while waiting, reach the network — gets a plain explanation instead of a raw runtime error.

Which C# version?

C# 14, the latest language version, including collection expressions, primary constructors, extension members and the field keyword. The runtime underneath is .NET 10, so the base class library is the current one too.

Does it work offline?

Yes, after one visit. The first time you open the page your browser downloads the compiler and runtime, about 18 MB, and keeps them. From then on the editor, completion, errors and running all work with no connection. The status bar shows "Available offline" once everything is stored.

Is my code uploaded?

No. Your code is compiled and run in a background worker inside this browser tab, and saved only in your browser's local storage so it survives a reload. Programs can't reach other sites or send your data anywhere off this site, either.

Why doesn't .Result or Thread.Sleep work?

WebAssembly in the browser is single-threaded, so anything that blocks a thread while waiting — .Result, .Wait(), Thread.Sleep, waiting on a lock — cannot work. Use await instead: await Task.Delay(100) rather than Thread.Sleep(100). The playground explains this whenever it happens.

Can I use NuGet packages?

No. The playground compiles a single file against the .NET base class library, which covers collections, LINQ, text, regular expressions, JSON, dates and maths. There is no package restore and no network access.

How do I read input?

Type the lines into the stdin box before you press Run. Each Console.ReadLine() call takes the next line; when the lines run out it returns null, exactly as a real console does at the end of its input.

Related tools