csharp-scripts

Solid

Run single-file C# programs as scripts (file-based apps) for quick experimentation, prototyping, and concept testing. Use when the user wants to write and execute a small C# program without creating a full project.

Testing & QA 3,357 stars 247 forks Updated today MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# C# Scripts ## When to Use - Testing a C# concept, API, or language feature with a quick one-file program - Prototyping logic before integrating it into a larger project ## When Not to Use - The user needs a full project with multiple files or project references - The user is working inside an existing .NET solution and wants to add code there - The program is too large or complex for a single file ## Inputs | Input | Required | Description | |-------|----------|-------------| | C# code or intent | Yes | The code to run, or a description of what the script should do | ## Workflow ### Step 1: Check the .NET SDK version Run `dotnet --version` to verify the SDK is installed and note the major version number. File-based apps require .NET 10 or later. If the version is below 10, follow the [fallback for older SDKs](#fallback-for-net-9-and-earlier) instead. ### Step 2: Write the script file Create a single `.cs` file using top-level statements. Place it outside any existing project directory to avoid conflicts with `.csproj` files. ```csharp // hello.cs Console.WriteLine("Hello from a C# script!"); var numbers = new[] { 1, 2, 3, 4, 5 }; Console.WriteLine($"Sum: {numbers.Sum()}"); ``` Guidelines: - Use top-level statements (no `Main` method, class, or namespace boilerplate) - Place `using` directives at the top of the file (after the `#!` line and any `#:` directives if present) - Place type declarations (classes, records, enums) after all top-level statements ### S...

Details

Author
dotnet
Repository
dotnet/skills
Created
4 months ago
Last Updated
today
Language
C#
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category