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
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-sensitiveThis 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#!");
}
}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#!");
}
}Which statement about indentation in C# is correct?
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.
In C#, a file containing your code must end with the extension ____.
C# Program Structure
10 questions · pass with 60% — just like in the app.
What best describes a class in C#?
A class name conventionally starts with a lowercase letter in C#.
A C# program begins its execution in the ____ method.
Which keyword in the Main() signature means the method doesn't return a value?
A statement in C# must always end with a semicolon.
C# executes a program's statements ____ (from top to bottom).
Curly braces { } group statements into a ____.
Every opening curly brace { needs a matching closing brace }.
Does the name of a C# file have to match the name of a class inside it?
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 →