C# · Chapter 3.1 · Basic level

C#'s 3 Golden Rules & Console.WriteLine()

C# के 3 सुनहरे नियम और Console.WriteLine()

Welcome to C# (pronounced 'C-Sharp') — Microsoft's super-fast language used to build 70%+ of mobile & PC games in Unity (Subway Surfers, Temple Run, Genshin, Hollow Knight)! Don't get scared by the wrapper lines — let's understand EVERY word once and forever:
1. Semicolon ; Rule: Just like English sentences end with ., every C# command MUST end with ;!
2. Capital Letters Rule: In Console.WriteLine(...), C, W, and L are ALWAYS Capital!
3. Curly Braces { } Rule: Every block starts with { and closes with }.

C# ('सी-शार्प') में स्वागत है — दुनिया के 70% से ज़्यादा मोबाइल और PC गेम्स (Unity Engine) इसी भाषा से बनते हैं! इसके शुरुआती शब्दों से बिल्कुल मत घबराओ — आज हर एक शब्द का मतलब हमेशा के लिए समझ लो:
1. सेमीकोलन ; नियम: जैसे हिंदी में पूर्णविराम । लगता है, C# की हर कमांड के अंत में ; लगाना 100% ज़रूरी है!
2. कैपिटल अक्षर नियम: Console.WriteLine(...) में C, W, और L हमेशा बड़े (Capital) अक्षर में होते हैं!
3. कर्ली ब्रैकेट { } नियम: हर कोड ब्लॉक { से शुरू और } पर बंद होता है।

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

using System;
Brings Microsoft's basic System toolbox (which contains Console) into your game.
Microsoft का बुनियादी System टूलबॉक्स (जिसमें Console रखा है) आपके प्रोग्राम में लाता है।
class Program { ... }
Main container blueprint named Program that holds your code.
Program नाम का मुख्य कंटेनर/डिब्बा जिसके अंदर सारा कोड रहता है।
static void Main()
Entry Gate — when you press Run, the computer ALWAYS starts reading inside Main()!
मुख्य दरवाज़ा (Starting Gate) — Run दबाते ही कंप्यूटर सबसे पहले Main() के अंदर से चलना शुरू करता है!
Console.WriteLine("...");
Prints a message on the Console AND makes our 2D Game Hero speak it! (C, W, L capital!).
कंसोल पर मैसेज छापता है और गेम हीरो के स्पीच-बबल में बुलवाता है! (C, W, L कैपिटल!)।
; (Semicolon)
C#'s full stop — mandatory at the end of every command line.
C# का पूर्णविराम — हर कमांड लाइन के आख़िर में लगाना अनिवार्य है।

Ready example

using System;

class Program {
    static void Main() {
        Console.WriteLine("Hello Future Game Developer!");
    }
}

What you will see: In the Mini 2D Game Stage, our Hero waves and speaks your exact message inside a comic speech bubble!

मिनी 2D गेम स्टेज पर हमारा हीरो हाथ हिलाएगा और स्पीच बबल में आपका लिखा मैसेज बोलेगा!

Line by line

using System;
Loads the standard System library.
System लाइब्रेरी लोड करता है।
class Program {
Opens the Program class container.
Program क्लास का ब्लॉक खोलता है।
static void Main() {
Opens the Main starting point of the program.
प्रोग्राम के शुरुआती दरवाज़े Main() को खोलता है।
Console.WriteLine("Hello Future Game Developer!");
Prints the greeting and shows it in the Hero's speech bubble!
मैसेज प्रिंट करता है और हीरो हाथ हिलाकर यही डायलॉग बोलता है!
} }
Closes Main() first, then closes class Program.
पहले Main() बंद किया, फिर class Program बंद किया।

Common mistake

✗ Wrong

console.writeline("Hello")

✓ Right

Console.WriteLine("Hello");

C# is strictly case-sensitive (C, W, L Capital!) and every statement ends with a semicolon ;!

C# में Console.WriteLine के C, W, L बड़े (Capital) होने चाहिए और अंत में सेमीकोलन ; अनिवार्य है!

Your task

Write Console.WriteLine("Main C# seekh raha hun!"); (don't forget ;!) and click ▶ Run & Preview!

Console.WriteLine("Main C# seekh raha hun!"); लिखो (आख़िर में ; लगाना मत भूलना!) और ▶ Run & Preview दबाओ!

  1. Inside Main(), write Console.WriteLine("Main C# seekh raha hun!");.
    Main() के अंदर Console.WriteLine("Main C# seekh raha hun!"); लिखो।
  2. Check that C, W, L are Capital and ; is at the end.
    जाँच लो कि C, W, L कैपिटल हैं और अंत में ; लगा है।
  3. Click ▶ Run & Preview to hear the Hero speak!
    ▶ Run & Preview दबाकर हीरो को बोलते देखो!
Starter code for the task
using System;

class Program {
    static void Main() {
        // TODO: yahan Console.WriteLine("Main C# seekh raha hun!"); likho
        // Yaad rakho: C, W, L capital hain aur aakhir mein ; zaroori hai
    }
}

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

Recap

Quick quiz

Every normal statement line in C# must end with which character?

C# में हर सामान्य कमांड लाइन के अंत में कौन-सा चिह्न लगाना अनिवार्य है?

  1. : (Colon)
  2. . (Dot)
  3. ; (Semicolon)
  4. , (Comma)
Show the answer

Answer: C (; (Semicolon))

Semicolon ; acts as the full-stop at the end of C# statements!

सेमीकोलन ; C# में वाक्य के पूर्णविराम (Full-stop) का काम करता है!

Practice problems for this chapter

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