C# playground

Run C# online

Write, compile and run C# online with .NET 10. A free C# compiler in your browser, with Console input and compiler errors shown. No sign-up needed.

Code Program.cs

// Welcome to the coding.kitty C# playground.
// Press Run (or Ctrl+Enter) to compile this and see what it prints.

var cats = new List<Cat>
{
    new("Miko", 3),
    new("Nola", 5),
    new("Baymax", 1),
};

// Youngest first.
var number = 1;
foreach (var cat in cats.OrderBy(c => c.Age))
{
    Console.WriteLine($"{number}. {cat.Name} is {cat.Age} and says meow");
    number++;
}

// Type a name in the Input box and press Run again to see this line.
var name = Console.ReadLine();
if (!string.IsNullOrWhiteSpace(name))
{
    Console.WriteLine($"Hello, {name}!");
}

record Cat(string Name, int Age);
Output

Press Run to see what your code prints.

About this C# playground

This is a C# compiler you can use straight away. Write C# in the editor, press Run, and your program is compiled with the C# compiler and run on .NET. The output appears next to it: everything it prints, any compiler error or warning with its line number, any exception with its stack trace, and how long it took.

It compiles as C# 14 on .NET 10 in an isolated sandbox on our servers, with top-level statements, so a program can be a single Console.WriteLine. It is free, with nothing to install and no account needed.

What you can run

  • C# 14, .NET 10, running one file per run, saved as Program.cs.
  • Compiled, then run. Each run compiles your file with csc -nullable:enable -out:main.dll Program.cs and runs the program if it compiles. Compiler errors and warnings appear in the output like any other error.
  • Standard library only. The whole .NET base class library is there: collections, LINQ, strings, System.Text.Json, System.IO, tasks and the rest. The usings a new console project starts with (System, System.Linq, System.Collections.Generic and more) are already in place. There is no package installer, and programs have no network access.
  • Limits: 10 seconds and 256 MB of memory per run, plus up to 20 seconds to compile first. Output past 64 KB is cut off, code can be up to 64 KB and input up to 16 KB.
  • Fair use: 5 runs a minute and 50 a day without an account, 10 a minute when you are signed in.

Reading input

Open the Input box under the editor and type what your program should read. Console.ReadLine() reads it a line at a time, and returns null once there is nothing left to read, straight away when the box is empty.

string? line = Console.ReadLine();
int age = int.Parse(line ?? "0");

Frequently asked questions

Is this online C# compiler free?

Yes. There is no sign-up and no limit on how much you can write. Signed-out visitors get a quick, usually invisible bot check when they press Run, and a fair-use cap of 5 runs a minute and 50 a day. Signing in raises it to 10 runs a minute.

Which version of C# and .NET does it use?

C# 14 on .NET 10, the current long-term support release, on Linux. Nullable reference types are on, as in a new dotnet project, so the compiler warns where something might be null. Records, pattern matching, LINQ and async and await all work.

Do I need a class with a Main method?

No. Top-level statements are the default, as in dotnet new console: write your statements at the top of the file and any classes or records below them. A class with a static Main method works too.

Can I use NuGet packages?

No. The playground compiles one file, Program.cs, against the .NET base class library. There is no NuGet and no network, so HttpClient calls to other sites fail, but everything in .NET itself is available.

Why does compiling take a few seconds?

The C# compiler is itself a .NET program, and starting it up takes three or four seconds even for a small file. Compiling has 20 seconds of its own, separate from your program's time, so a slow compile never cuts your program short.

Why did my program stop with a time-out?

Compiling gets up to 20 seconds of its own. Then the program gets 10 seconds and 256 MB of memory, and is stopped if it goes past either. The usual cause is a loop that never ends, such as a while loop whose condition never turns false.

Is my code saved or shared?

Your code is kept in your own browser so it is still there next time, and nowhere else. When you press Run it is sent to our code runner, run once in a sandbox, and thrown away. We do not store it or show it to anyone.

Keep going

Also in the playground: Python, JavaScript, TypeScript, SQL, Bash, C, C++, Go, Rust, Java, Ruby, PHP, Lua, R, Dart, Swift.