C# · Chapter 3.0 · Start Here level

Start Here: How a C# Program Runs (Compile → Run)

शुरुआत: C# प्रोग्राम कैसे चलता है (Compile → Run)

C# is a compiled language: before running, the compiler checks your WHOLE program like a strict exam checker. If even one ; is missing, it refuses to run and shows an error like CS1002: ; expected — so the output stays empty. That's good: mistakes are caught early! Every C# program has a fixed shape: class Program { static void Main() { ...your code... } }. Think of Main() as the main gate — the computer always enters there first. The same C# runs real Unity games!

C# एक compiled भाषा है: चलाने से पहले compiler आपका पूरा प्रोग्राम एक सख्त परीक्षक की तरह जाँचता है। अगर एक भी ; छूटा, तो वह चलाने से मना कर देता है और CS1002: ; expected जैसी error दिखाता है — इसलिए आउटपुट खाली रहता है। यह अच्छा है: गलतियाँ जल्दी पकड़ी जाती हैं! हर C# प्रोग्राम का एक तय ढाँचा होता है: class Program { static void Main() { ...आपका कोड... } }। Main() को मुख्य दरवाज़ा समझो — कंप्यूटर हमेशा वहीं से अंदर आता है। यही C# असली Unity गेम्स चलाती है!

In the classroom you can run and edit this code in your browser, get hints and mark the chapter as done. क्लास में यह code ब्राउज़र में चलाकर बदल सकते हो।

Words and symbols in this chapter

Compiler
Checks the full program for mistakes before it runs.
प्रोग्राम चलने से पहले पूरे कोड की गलतियाँ जाँचता है।
error CS1002
Compile errors have a CS number — search it to learn more.
Compile errors का CS नंबर होता है — उसे खोजकर और सीख सकते हो।
static void Main()
The entry gate: execution starts on its first line.
प्रवेश द्वार: चलना इसकी पहली लाइन से शुरू होता है।
{ }
Curly braces wrap a block: one for the class, one for Main.
Curly braces एक block को घेरते हैं: एक class के लिए, एक Main के लिए।

Ready example

using System;

class Program {
    static void Main() {
        Console.WriteLine("Game shuru!");
        Console.WriteLine("Player: Rohan");
        Console.WriteLine(10 + 5);
    }
}

What you will see: Your messages appear in the console and in the hero's speech bubble.

आपके संदेश console में और हीरो के speech bubble में दिखेंगे।

Line by line

class Program {
The container for our code.
हमारे कोड का डिब्बा।
static void Main() {
Execution starts here.
यहीं से प्रोग्राम चलना शुरू होता है।
Console.WriteLine("Game shuru!");
Prints a line; ends with ;.
एक लाइन छापता है; आख़िर में ;।
Console.WriteLine(10 + 5);
C# calculates first and prints 15.
C# पहले जोड़ता है और 15 छापता है।

Common mistake

✗ Wrong

static void main() {

✓ Right

static void Main() {

C# is case-sensitive: the entry point is Main with a capital M.

C# में बड़े-छोटे अक्षर मायने रखते हैं: entry point Main है, कैपिटल M के साथ।

Your task

Run once to see CS1002, add the missing ;, then print one more line with your name.

एक बार Run करके CS1002 देखो, छूटा हुआ ; लगाओ, फिर अपने नाम वाली एक और लाइन print करो।

  1. Run and read: error CS1002: ; expected on line 6.
    Run करो और पढ़ो: लाइन 6 पर error CS1002: ; expected।
  2. Add ; at the end of the WriteLine line.
    WriteLine वाली लाइन के आख़िर में ; लगाओ।
  3. Add Console.WriteLine("Mera naam: Simran"); (your name) and Run.
    Console.WriteLine("Mera naam: Simran"); (अपना नाम) जोड़ो और Run करो।
Starter code for the task
using System;

class Program {
    static void Main() {
        // Is line mein ; chhoot gaya hai — Run karke error padho, phir theek karo:
        Console.WriteLine("Mera pehla C# program")
        // TODO: ek aur Console.WriteLine likho jisme aapka naam ho
    }
}

Do this task in the classroom: your code is checked automatically and you get hints if something is missing.

Recap

Quick quiz

A C# program has one missing ;. What happens?

C# प्रोग्राम में एक ; छूट गया। क्या होगा?

  1. It runs and skips that line
  2. The compiler shows an error and nothing runs
  3. It prints the line twice
  4. C# adds it automatically
Show the answer

Answer: B (The compiler shows an error and nothing runs)

Compile errors stop the whole program before it starts.

Compile error पूरे प्रोग्राम को शुरू होने से पहले ही रोक देती है।

More practice at this level

Solve them in the Practice Zone, where each answer is checked automatically and two hints are available.