C# course for beginners, with game examples
C# प्रोग्रामिंग कोर्स (हिंदी + English)
Learn C# with small game-style examples such as player coins, health and weapons. You see how a C# program is compiled and run, then learn Console.WriteLine, strict data types, if/else, loops, methods, classes and objects, arrays and foreach, methods that return values, List<T>, constructors and properties, and inheritance with polymorphism. The capstone is a small text RPG battle.
C# को छोटे game जैसे उदाहरणों (player के coins, health, weapon) से सीखो। पहले समझो कि C# program compile होकर कैसे चलता है, फिर Console.WriteLine, strict data types, if/else, loops, methods, classes और objects, arrays और foreach, value लौटाने वाले methods, List<T>, constructors और properties, और inheritance व polymorphism। आख़िर में एक छोटा text RPG battle बनता है।
- 13 chapters in four levels: Start, Basic, Intermediate and Pro
- 12 practice problems with automatic checks and hints
- a quiz question in every chapter, plus 9 viva and interview questions
- free, no sign-up; works on a phone or a computer
How the code runs: Code runs in a small C# interpreter written in JavaScript. It supports the features used in these lessons and shows real C# error codes such as CS1002, but it is not the full .NET platform; for real projects install the .NET SDK or Unity. Code JavaScript में लिखे एक छोटे C# interpreter में चलता है। यह इन lessons के features और CS1002 जैसे असली C# error codes दिखाता है, पर यह पूरा .NET नहीं है; असली projects के लिए .NET SDK या Unity इंस्टॉल करें।
Start Here level
- 3.0Start Here: How a C# Program Runs (Compile → Run)
C# is compiled: one mistake and nothing runs — read the CS error.
Basic level
- 3.1C#'s 3 Golden Rules & Console.WriteLine()
Every C# statement ends with a semicolon
;. - 3.2Strict Data Types (Player Coins, Health & Weapon)
C# needs the type before the name:
int coins = 500;. - 3.3Game Logic (if-else Dragon Boss Gate!)
if (condition) { ... } else { ... }chooses what to run. - 3.4Loops in C# (Robot Enemy Spawner! )
for (int i = 1; i <= 5; i++)has 3 parts: start; keep-going check; step.
Intermediate level
- 3.5Methods (Player Actions: Jump() & Attack()!)
A method is a named, reusable action:
static void Attack() { ... }. - 3.6Classes & Objects (OOP — Pokemon Battle Generator!)
A
classis a blueprint; an object is a real thing made withnew. - 3.7Bonus: Hero Inventory Backpack (Arrays [] & foreach)
An array holds many values of one type:
string[] bag = { "Sword", "Shield" };. - 3.8Methods that Return Values + Math + User Input
Return type before the name (
int,double,string);void= nothing. - 3.9List<T> + while Loop + break/continue (Game Shop & Inventory)
List<string>grows and shrinks:Add,Remove,Contains,bag[0],bag.Count.
Pro level
- 3.10Constructors, Properties & Encapsulation (Protect Your Player Data)
A constructor (
public Player(...)) runs onnewand sets starting values — it has no return type. - 3.11Inheritance & Polymorphism (Enemy → Boss)
class Boss : Enemy— the child gets all fields and methods of the parent (inheritance). - 3.12Capstone: Mini RPG Battle (enum + switch + Random + classes + List + while)
enum Move { Punch, Kick, Block }names fixed choices;(Move)numberturns a number into a choice.
Practice problems
Each problem is linked to a chapter. Read them on the practice page and solve them in the Practice Zone.
- Fix the Game Loading Screen (3 compile errors)
- Game Hero Profile (data types)
- Railway Ticket Fare (if / else if / else)
- Predict: Enemy Waves (for loop + int division)
- Combo Buttons (static void methods)
- IPL Player Cards (class & object — fill the blanks)
- Predict: The Hero's Backpack (array + foreach)
- Electricity Bill Method (return + ReadLine)
- Game Shop (List<T> + while + break)
- Fix the Bank Account (encapsulation bugs)
- Boss Battle (inheritance + override)
- Mini Project: Arjun vs Mahishasura RPG Battle
Viva and interview questions
What is C# and where is it used in the real industry?
C# (C-Sharp) is Microsoft's modern, strongly-typed OOP language. It powers Unity 2D/3D video games (over 60% of mobile/indie games!), enterprise .NET backends, and Windows apps.
C# क्या है और असली इंडस्ट्री में इसका उपयोग कहाँ होता है?
C# (सी-शार्प) Microsoft की आधुनिक और तेज़ भाषा है। दुनिया के 60%+ मोबाइल और 3D गेम्स (Unity Engine), बैंकिंग सॉफ्टवेयर और Windows ऐप्स C# में बनते हैं।
Why is C# called a 'Strictly Typed' language compared to Python?
In C#, you must declare the exact data type (int, double, string, bool) when creating a variable, catching type mistakes early before the game even runs!
Python की तुलना में C# को 'Strictly Typed' भाषा क्यों कहा जाता है?
C# में वेरिएबल बनाते समय ही उसका पक्का टाइप (int, string, bool) बताना पड़ता है — इससे बड़े गेम्स में गलतियाँ तुरंत पकड़ में आ जाती हैं।
What is the role of static void Main() in C#?
Main() is the entry gate of a C# application — when you run the program, execution always begins from the first line inside Main().
C# प्रोग्राम में static void Main() का क्या काम होता है?
Main() किसी भी C# प्रोग्राम का मुख्य दरवाज़ा (Entry Point) है — प्रोग्राम रन होते ही सबसे पहले Main() के अंदर लिखा कोड चलता है।
Explain Class vs Object with a game example!
A class Pokemon is a single blueprint defining name, power, and Attack(). Using new Pokemon(), we can spawn 100 live Objects (Pikachu, Charizard, Mewtwo) from that one blueprint!
गेम के उदाहरण से Class और Object का अंतर समझाइए!
class Pokemon एक कागज़ का नक्शा (Blueprint) है। new Pokemon() लिखकर हम उसी एक नक्शे से सैकड़ों असली किरदार (Objects जैसे Pikachu, Charizard) मैदान में उतार सकते हैं!
What happens if you access index bag[3] in a 3-item C# array?
It throws an IndexOutOfRangeException because 3 items sit at indexes 0, 1, and 2!
3 आइटम वाले C# ऐरे में bag[3] लिखने पर क्या होगा?
IndexOutOfRangeException एरर आएगा क्योंकि 3 आइटम्स के इंडेक्स 0, 1 और 2 होते हैं (3 नहीं)!
Why is foreach preferred when reading all items of an array?
foreach (string item in bag) visits every element cleanly without manual index math, eliminating off-by-one IndexOutOfRangeException bugs.
ऐरे के सारे आइटम्स पढ़ने के लिए foreach क्यों पसंद किया जाता है?
foreach बिना इंडेक्स गिनती की झंझट के अपने-आप पहले से आखिरी आइटम तक सुरक्षित रूप से चलता है।
What is encapsulation in C#?
Keeping fields private and exposing them only through public properties or methods that apply rules — e.g. a Health property whose set keeps the value between 0 and 100.
C# में encapsulation क्या है?
Fields को private रखना और उन्हें सिर्फ़ नियम लगाने वाली public properties या methods से खोलना — जैसे Health property जिसका set वैल्यू को 0 से 100 के बीच रखता है।
Explain virtual, override and polymorphism with an example.
Enemy has public virtual void Attack() and Boss : Enemy writes public override void Attack(). In a List<Enemy>, calling e.Attack() runs the Boss version for bosses and the normal version for the others — one call, many forms.
virtual, override और polymorphism को उदाहरण से समझाओ।
Enemy में public virtual void Attack() है और Boss : Enemy में public override void Attack()। List<Enemy> में e.Attack() बुलाने पर बॉस के लिए Boss वाला version और बाकी के लिए सामान्य version चलता है — एक कॉल, कई रूप।
When do you use List<T> instead of an array?
Use an array when the number of items is fixed (string[], .Length). Use List<T> when items are added or removed while the program runs (Add, Remove, .Count).
Array की जगह List<T> कब इस्तेमाल करते हैं?
जब items की संख्या तय हो तो array (string[], .Length)। जब प्रोग्राम चलते समय items जुड़ें या हटें तो List<T> (Add, Remove, .Count)।
Ready mini projects
- Dragon Boss Arena Battle: Full C# mini-game script combining stats, Boss unlock, enemy wave, Jump & Attack!
- Pokemon OOP Stadium Battle (C#): Spawns live
Pokemonobjects from a C# Class blueprint and triggers stadium attacks! - RPG Hero Loot & Backpack Crafter: Demonstrates C#
string[]arrays,.Length, slot upgrade, andforeachloop!
Open them in the Projects section of the classroom to run and change the code.