Skip to content
KodeTrail

Camp 1 · Step 2 of 12

Hello, .NET!

Run modern C#, print with WriteLine, and use interpolation — the friendly front door.

10 min+50 XP

Modern C# lets you start with almost no ceremony. Let's write real programs from line one.

Printing

C#Cloud run
  • Console.WriteLine(...) — print with a newline
  • Console.Write(...) — print without one
  • Console is C#'s gateway to the terminal, from the .NET library

String interpolation

Prefix a string with $ and embed expressions in { }:

C#Cloud run

The same idea you've seen across this trail — Python's f-strings, Swift's \(...), C#'s $"...{...}". Modern languages converged on the same good idea.

Where's the class and Main?

Traditional C# wraps everything in a class and a Main method:

class Program {
    static void Main() {
        Console.WriteLine("Hello");
    }
}

Top-level statements (modern C#) let you skip that boilerplate for simple programs — the compiler adds it invisibly. You'll meet classes properly in Camp 4; for now, enjoy the clean start.

Checkpoint

What's the difference between Console.WriteLine and Console.Write?

Checkpoint

In $"Total: {a + b}", what does {a + b} do?

What's next

Variables and types — C#'s strong, friendly type system.