Write and run C# in your browser — no installation needed. Uses the Piston API (Mono runtime) to compile and execute your code securely.
Press Tab inside the editor to insert 4 spaces.
Click ▼ stdin and type your inputs — one per line, matching each ReadLine() call.
System, System.Collections.Generic, System.Linq, System.IO and more are all available.
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"));