Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

C# Program Structure · Lesson 13 of 27

Code Blocks

A free lesson from Swipe Coding · C#, level 1 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Curly braces are how C# knows where a group of code starts and ends. 🧱

Curly braces { } group multiple statements together into a shared block in C#. A block marks a clear beginning and a clear end — for example the body of a class or the body of a method.

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, C#!");
    }
}
The outer curly braces belong to the class "Program", the inner ones to the Main() method.
🤖
See how one block can live neatly inside another. 📦

Blocks can be nested inside one another, similar to a box inside another box. The block of the Main() method lies completely inside the block of the class — it starts later and ends earlier than the class block.

class Program { // Start of class block
    static void Main() { // Start of method block
        Console.WriteLine("Hello, C#!");
    } // End of method block
} // End of class block
Marked with comments, you can clearly see: the method block lies entirely within the class block.
Quick check

What are curly braces { } used for in C#?

🤖
Miss a closing brace and the compiler will let you know. ⚠️

Every opening brace { must eventually have a matching closing brace }. If one is missing, the compiler can't tell where a block ends and reports an error — even if the rest of the code is correct.

True or false

Every opening curly brace { needs a matching closing brace }.

As a reminder: the class itself is a block, the Main() method is another block inside it, and the individual statements from the last lesson sit inside these blocks. That's how everything in a C# program fits together.

Fill in the blank

The block of the Main() method lies ____ the block of the class.

Keep your streak going in Swipe Coding

Swipe through every level of C# on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →