Online C# Compiler
Write, run and test C# code online, right in your browser. This free online C# compiler needs no installation or signup — just type your code and click Run.
C# is a modern, object-oriented language from Microsoft, used with .NET to build desktop apps, web APIs, cloud services and Unity games.
How to use the C# compiler
- Write or paste your C# code in the editor.
- If your program reads input, open the I/O tab and type it into the STDIN box (one value per line).
- Click Run — the output and any errors appear in the output panel.
Sample: read input in C#
using System;
class Program
{
static void Main()
{
string name = Console.ReadLine();
Console.WriteLine($"Hello, {name}!");
}
}
Paste this into the editor, type your name in the STDIN box and click Run.
More C# examples to try
Parse numbers from input
Reads a line of space-separated numbers and prints their sum using LINQ. Try STDIN 10 20 30.
using System;
using System.Linq;
class Program
{
static void Main()
{
int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
Console.WriteLine($"Sum: {nums.Sum()}, Max: {nums.Max()}");
}
}
Classes and lists
A class with properties stored in a List<T> and filtered with LINQ.
using System;
using System.Collections.Generic;
using System.Linq;
class Product
{
public string Name { get; set; }
public decimal Price { get; set; }
}
class Program
{
static void Main()
{
var products = new List<Product>
{
new Product { Name = "Pen", Price = 20 },
new Product { Name = "Notebook", Price = 60 },
new Product { Name = "Bag", Price = 750 }
};
foreach (var p in products.Where(p => p.Price < 100))
Console.WriteLine($"{p.Name}: {p.Price}");
}
}
Common C# errors and how to fix them
error CS0103: The name 'x' does not exist in the current context- The variable is misspelled or declared inside another block. C# names are case-sensitive.
System.FormatException: Input string was not in a correct formatint.Parsereceived text that is not a number — often an empty line. Check the STDIN box, or useint.TryParse.System.NullReferenceExceptionConsole.ReadLine()returnednullbecause no input was given, or an object was never created. Add input in STDIN or check for null.error CS1002: ; expected- A statement is missing its semicolon on the line shown in the error.
Frequently asked questions
Is this online C# compiler free?
Yes. It is completely free to use, with no signup required to write and run code.
Do I need to install anything?
No. It all works from your web browser, so there is nothing to download or set up — it works on Windows, macOS, Linux, Chromebooks and phones.
How do I give input to my C# program?
Before clicking Run, type the input into the STDIN box under the I/O tab, one value per line. Your program reads it as standard input, just like typing in a terminal.
Is this good for learning C#?
Yes. It is ideal for practising exercises, testing small programs and trying out ideas from tutorials, because you can run code instantly without configuring an environment.
Other online compilers
Python Compiler Java Compiler C Compiler C++ Compiler JavaScript Compiler TypeScript Compiler SQL Compiler React.js Compiler HTML Compiler Go Compiler Rust Compiler R Compiler PHP Compiler Kotlin Compiler Swift Compiler Scala Compiler Dart Compiler Ruby Compiler Prolog Compiler Perl Compiler
Editor powered by OneCompiler.