What is a program? Hello, C#

Programs, Main, and printing.

1. What is this?

A program is instructions the computer runs. In C#, code lives in a class, and execution starts in a method called Main. Console.WriteLine(...) prints a line. A string is text in double quotes. Top-level statements (just Console.WriteLine(...);) also work in modern C# — but seeing the full class form teaches you what is really happening.

2. Why do we use it?

C# builds desktop apps, Unity games, and web APIs. One language across many platforms.

3. Syntax breakdown

  • class Program {

    Container for the code. Classes group behaviour.

  •   static void Main() {

    Entry point. static lets the runtime call it without an object.

  •     System.Console.WriteLine("Hello");

    Prints Hello. Statements end with ;.

5. Common mistakes

  • Lowercase string — the type is string (lowercase in C#) but String also works; be consistent.
  • Forgetting the semicolon.
  • Naming the entry method main (lowercase) — it must be Main.

Practice task

Print your name, then "Learning C# step by step."

Hint

Add a second WriteLine below the first.

Try it below — tests run automatically when you press Run.

csharp

Output

Press Run to see output.

Mini quiz

3 questions. Answer, then check.

  1. 1. Where does a C# program start?

  2. 2. What does WriteLine do?

  3. 3. How do statements end?

4. Example — edit and run

csharp

Output

Press Run to see output.

Expected output: Hello, I am learning C#