Simple C# Editor Online
/* Simple Online C# Editor */
using System;
class HelloWorld {
static void Main() {
Console.WriteLine("Hello World");
}
}
About This C# Editor
C# runs on .NET, which since .NET Core has been cross-platform and open source. The language has absorbed a great deal from functional programming over the years - LINQ, pattern matching, records, nullable reference types - while staying recognisably in the C family.
The editor highlights LINQ, attributes, generics and interpolated strings, and matches braces across long class bodies.
Modern C# syntax
| Syntax | What it does |
|---|---|
record Person(string Name, int Age); |
Immutable reference type with value equality and a deconstructor. |
var adults = people.Where(p => p.Age >= 18).Select(p => p.Name); |
LINQ method syntax. Deferred until enumerated. |
string? name = null; |
Nullable reference type. The compiler warns when you dereference without a check. |
x switch { > 100 => "big", _ => "small" } |
Switch expression with relational patterns. |
$"Hello {name}, you are {age:N0}" |
Interpolated string with a format specifier. |
await foreach (var item in stream) |
Asynchronous streams over IAsyncEnumerable. |
using var conn = new SqlConnection(cs); |
Declaration-form using - disposed at end of scope. |
public int Count { get; init; } |
init-only setter: settable in an object initialiser, immutable afterwards. |
Where C# code goes wrong
- async void. Only ever for event handlers. Exceptions from an
async voidmethod cannot be caught by the caller and will take down the process. ReturnTask. - Blocking on async.
.Resultand.Wait()deadlock in any context with a synchronisation context. Await all the way up. - Deferred LINQ execution. A query is not run until enumerated, so a query over a changing collection gives different answers at different times. Call
ToList()to materialise. - struct versus class. Structs are value types and are copied on assignment, which surprises people who mutate a struct held in a collection.
- String concatenation in loops allocates a new string each iteration. Use
StringBuilder.
Your Code Never Leaves Your Browser
The editor is JavaScript running in this tab. Nothing you type is posted to a server, stored, logged or associated with you, and there is no account and no autosave. That makes it safe to paste a snippet from a private codebase in order to read it with highlighting. The trade-off is that nothing persists either — refresh the page and your content is gone, so copy anything you want to keep.
Frequently Asked Questions
Can I compile C# here?
No. Compiling needs the .NET SDK, and this page has no runtime attached - it is an editor for reading and formatting code, and nothing you type is uploaded.
Is C# only for Windows?
Not since .NET Core. Modern .NET runs on Linux and macOS, and ASP.NET Core services are routinely deployed to Linux containers. Only the older .NET Framework is Windows-only.
What is the difference between const and readonly?
const is resolved at compile time and baked into the calling assembly, so changing it requires recompiling every consumer. readonly is assigned at runtime in the constructor and can differ per instance.
Editors for Other Languages
Same editor, configured for a different language, each with its own syntax reference.