C# scripting (dotnet script), snippets & REPL
Run small C# snippets quickly: what scripting is, typical use-cases, and how script code maps to a Program.Main in normal apps.
Concept & use-cases
C# scripting lets you run small bits of C# without creating a project.
- Great for quick tests and utilities
- Good for demos and learning
- Shares the same language/runtime ideas as normal apps
From snippet to app
Scripts often use top-level statements. In normal apps, the same idea lives inside Program.Main.
using System;
// In a script, you can write Console.WriteLine("Hi") at top-level.
// Here we show the equivalent in a normal app (C# 6 friendly).
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello from a small snippet!");
// In scripting, this could be a one-liner without class/namespace.
}
}
All lessons in this course
- C# scripting (dotnet script), snippets & REPL
- Interop basics (P/Invoke) at a glance
- CLI ergonomics