Create and edit a C# file
Open Codectionary’s Playground from the site navigation. In the file explorer, select New File (+) and choose C#. The editor creates an untitled .cs file; you can rename it, type C# code and use C# syntax highlighting. A documentation example opened with Edit in Playground also appears as a .cs file.
The Playground can hold multiple editable files in its explorer. That is useful for drafting or comparing snippets, but it is not a .NET project: creating several .cs files here does not build them together. Copy code you want to keep before reloading or leaving the page; the Playground warns that work is not saved automatically.
What happens when you press Run?
The current Playground does not compile C# and does not execute C# code. Pressing Run refreshes the web preview and adds a warning in the Console panel that the .cs file will not run. It does not display your C# program’s output, compiler diagnostics or runtime errors.
The preview is for an HTML page with CSS and browser JavaScript or TypeScript. If your project contains no HTML file, it shows “No HTML file found”; adding an HTML file does not make C# execute. The Playground’s remote code runner accepts Java and C++ only, and the Language support panel lists C# as “Editing only”. A warning about unsupported execution is different from a C# compilation error.
Multiple files and NuGet packages
You can create, switch between, rename and remove multiple files in the explorer, including more than one .cs file. The editor treats them as separate text files. There is no C# project build, .csproj restore, dependency resolution or NuGet package installation in this Playground.
A C# snippet that imports a package may be useful as a draft here, but the package will not become available merely because you type a using directive. Create a local .NET project and add the package with the .NET CLI when you need to build and test code that depends on NuGet.
Input, file operations and other restrictions
The optional Program input box appears for the Java and C++ remote runners, not C#. Because C# does not execute here, Console.ReadLine cannot read input and System.IO file operations cannot read or write files. The Console panel cannot show C# stdout, exceptions or compiler errors.
The editor can still help you write and inspect C# syntax. It cannot verify that a program compiles, runs correctly, accesses the file system or has the packages it needs. Do not treat a clean-looking, highlighted snippet as a successful build.
Run the same example locally
Install a supported .NET SDK for your operating system; a runtime-only installation cannot create or build a project. In a terminal, create a console project, replace its Program.cs with the code below, save it and run dotnet run from the project folder. The SDK compiles the C# source and launches the resulting app, so its output and any build or runtime errors appear in your terminal.
Use the first-program walkthrough for a complete explanation of each command and what to do if dotnet is not found. The operating-system guides cover installation and verification. For several source files, packages, input or file operations, continue in a local project rather than expecting the Playground preview to provide a .NET runtime.
Terminal — create and enter a project
dotnet new console -n FirstCSharp
cd FirstCSharpProgram.cs — replace its contents
Console.WriteLine("Hello, Codectionary!");Terminal — build and run
dotnet runChoose the right place for the task
Use the Playground to read, edit or compare short C# examples. Use a local .NET project when you need compilation, execution, compiler feedback, packages, input, file operations or debugging. After your first console program runs, learn how projects and solutions organise source files and how NuGet adds dependencies.
Syntax
Console.WriteLine("Hello, Codectionary!");Examples
A C# greeting to run in a local console project
This code is editable in the Playground, but requires a local .NET project to compile and run.
Console.WriteLine("Hello, Codectionary!");- Create a console project with dotnet new console, replace Program.cs with this line, and run dotnet run from the project folder.
- Console.WriteLine writes the string inside the parentheses followed by a newline; the semicolon ends the C# statement.
- The terminal prints Hello, Codectionary!. Pressing Run in Codectionary’s Playground instead shows a warning because the Playground does not execute C#.
Best practices
- Use the Playground for C# editing and syntax highlighting, not as a compiler or runtime.
- Keep a copy of important edits before leaving or reloading the Playground.
- Run C# examples in a local project with the .NET SDK when you need trustworthy output or compiler feedback.
- Add NuGet packages to a local project and verify behaviour there.
Runtime & versions
.NET runtime. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
C# language reference