← Tools / 🔷 C# Playground
Take the C# course →
🔷

C# Playground

Write and run C# in your browser — no installation needed. Uses the Piston API (Mono runtime) to compile and execute your code securely.

C#
⌨️

Keyboard shortcut

Press Tab inside the editor to insert 4 spaces.

📥

Using Console.ReadLine()

Click ▼ stdin and type your inputs — one per line, matching each ReadLine() call.

📦

Namespaces

System, System.Collections.Generic, System.Linq, System.IO and more are all available.

Quick-start snippets

Input & output

Console.Write("Name: ");
string name = Console.ReadLine();
Console.WriteLine($"Hello, {name}!");

for loop

for (int i = 1; i <= 10; i++)
    Console.WriteLine(i);

while loop

int n = 1;
while (n <= 10)
{
    Console.WriteLine(n);
    n++;
}

if / else if / else

int x = int.Parse(Console.ReadLine());
if (x > 0) Console.WriteLine("Positive");
else if (x < 0) Console.WriteLine("Negative");
else Console.WriteLine("Zero");

Array & foreach

int[] scores = {72,85,91,60};
int total = 0;
foreach (int s in scores) total += s;
Console.WriteLine($"Avg: {(double)total/scores.Length:F1}");

Method

static string Greet(string name)
    => $"Hello, {name}!";

Console.WriteLine(Greet("Alice"));