Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

C# Program Structure · Lesson 14 of 27

C# Syntax Basics

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

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

🤖
Time to pull together everything you have learned about the rules. 📋

You now know about classes, the Main() method, statements, and code blocks. Let's summarize a few basic syntax rules that apply to every C# program.

Console.WriteLine("Hello!"); // correct
console.writeline("Hello!"); // Error! C# is case-sensitive
C# is "case-sensitive" — capitalization makes a difference. "Console" and "console" are two completely different words as far as C# is concerned.
🤖
Case matters everywhere in C# — no exceptions. 🔠

This applies to everything in C#: class names, method names, keywords like "class" or "static". A single letter with the wrong capitalization leads to a compiler error.

Unlike some other languages, C# does not require the file name to match the name of a class inside it — a file can be named anything ending in ".cs". Even so, most C# developers name their file after the main class it contains, purely as a helpful convention.

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, C#!");
    }
}
This code would compile just fine whether it lives in "Program.cs", "Main.cs", or any other ".cs" file name.
True or false

C# is case-sensitive (for example, "Main" and "main" are different).

Indentation — meaning spaces at the start of a line that visually shift nested blocks inward — is, on the other hand, not necessary for the compiler. C# compiles code without any indentation just fine. Still, you should always indent cleanly, because it makes your code much easier for people to read.

class Program {
static void Main() {
Console.WriteLine("Hello, C#!");
}
}
This code compiles just fine — it's simply much harder to read without indentation than the indented version above.
Quick check

Which statement about indentation in C# is correct?

🤖
You now have the complete rulebook for any C# program. 📖

In summary, every C# program follows these rules: the code lives in a class, execution starts in the Main() method, every statement ends with a semicolon, related statements sit in a block of curly braces, and C# is case-sensitive throughout.

Fill in the blank

In C#, a file containing your code must end with the extension ____.

Chapter quiz

C# Program Structure

10 questions · pass with 60% — just like in the app.

Quick check

What best describes a class in C#?

True or false

A class name conventionally starts with a lowercase letter in C#.

Fill in the blank

A C# program begins its execution in the ____ method.

Quick check

Which keyword in the Main() signature means the method doesn't return a value?

True or false

A statement in C# must always end with a semicolon.

Fill in the blank

C# executes a program's statements ____ (from top to bottom).

Fill in the blank

Curly braces { } group statements into a ____.

True or false

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

Quick check

Does the name of a C# file have to match the name of a class inside it?

True or false

C# is case-sensitive.

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 →