Reading — step 1 of 6
Learn
Hello, C#
C# ("see sharp") was created at Microsoft in 2000 by Anders Hejlsberg — the same engineer behind Turbo Pascal, Delphi, and later TypeScript. It was designed as a modern, type-safe language for the .NET platform, and today it runs everywhere: Windows, Linux, macOS, game engines (Unity), and the cloud.
Understanding how a C# program starts tells you a lot about the language:
using System;
class Program {
static void Main() {
Console.WriteLine("Hello, C#!");
}
}
Take it line by line, because every piece is there for a reason:
using System;— C# organizes code into namespaces.Consolelives in theSystemnamespace; this directive lets you writeConsole.WriteLineinstead ofSystem.Console.WriteLineon every line.class Program— C# is class-based to the core: every piece of executable code lives inside a class. There is no such thing as a free-floating function.static void Main()— the entry point. When your program starts, the runtime looks for a method namedMainand calls it. It must bestaticbecause at startup no objects exist yet — the runtime calls it on the class itself, not on an instance.Console.WriteLine("...")— prints the text plus a newline. Its siblingConsole.Writeprints without the newline.
When you compile, C# does not become machine code directly. It compiles to IL (intermediate language), and the .NET runtime — the CLR, or Mono on this course's grader — turns IL into native code as the program runs. That is what makes the same compiled program portable across operating systems.
The idiom and the trap
// Idiom: WriteLine prints the text and ends the line
Console.WriteLine("Hello, C#!");
// Trap 1: C# is case-sensitive — this does not compile
console.writeline("Hello, C#!"); // error: 'console' does not exist
// Trap 2: forgetting the semicolon — every statement ends with one
Console.WriteLine("Hello, C#!") // error: ; expected
C# refuses to compile both — and that is good news. A compile error is the cheapest bug you will ever fix, because the compiler points straight at the line.
One more thing you may see elsewhere: modern .NET allows "top-level statements", where you skip class Program and Main entirely. The Mono runtime used by the grader here requires the explicit class-and-Main form — so always keep the full skeleton, exactly as the starter code gives it to you.
Your exercise
The starter has the skeleton ready, with a comment marking where your code goes. Replace the comment with one Console.WriteLine call that prints exactly:
Hello, C#!
The grader compares your output character by character. The mistakes it will catch: a missing exclamation mark (Hello, C#), a missing comma (Hello C#!), a lowercase h, or spelling out C sharp. Copy the target precisely — capital H, comma, space, C#, ! — and use WriteLine (not Write) so the line ends with a newline.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…