C# FOUNDATIONSChapter 1 · C# Foundations
Your first C# program
C# code lives inside classes and methods. A program starts in a special method called Main. To print a line of text, you call Console.WriteLine. Newer project templates let you skip writing Main by using top-level statements, but the compiler still creates it for you behind the scenes.
Worked example
using System;
class Program {
static void Main() {
Console.WriteLine("Hello, sky!");
}
}How it reads
- Console.WriteLine(...) prints a line of text to the console
- static void Main() is where the program starts running
- using System; brings in the namespace that contains Console

Cloud tip: C# statements end with a semicolon, and every line of code lives inside a class and a method.


