C# का असली खेल Classes और Objects से शुरू होता है।
अगर ये समझ गए, तो आप:
Billing Software
GPS Tracking Server
Mobile App Backend
School/College Management System
Games (Unity)
सब कुछ आसानी से बना सकते हो।
आज हम Class/Object को स्कूल की किताबें नहीं,
बल्कि Real Life Examples से समझेंगे।
Class = Blueprint (नमूना)
Object = Blueprint से बना हुआ असली product
Car की design = Class
Showroom में खड़ी actual car = Object
Design same, but हर car का रंग/नंबर/फीचर्स अलग
class Car
{
public string Color;
public string Model;
public void Start()
{
Console.WriteLine("Car Started");
}
}
Object = Class का real version।
Car myCar = new Car();
myCar.Color = "Black";
myCar.Model = "Swift";
myCar.Start();
यहाँ myCar एक object है — असली गाड़ी।
School/College का software 100% Classes/Objects पर चलता है।
class Student
{
public int RollNo;
public string Name;
public int Marks;
public string GetResult()
{
return Marks >= 33 ? "Pass" : "Fail";
}
}
Student s = new Student();
s.RollNo = 101;
s.Name = "Rahul";
s.Marks = 78;
Console.WriteLine(s.GetResult()); // Pass
हर student एक object है, लेकिन class एक ही।
Amazon, Flipkart के products objects होते हैं।
class Product
{
public string Name;
public double Price;
}
Product p1 = new Product { Name = "Mobile", Price = 10000 };
Product p2 = new Product { Name = "Shoes", Price = 1500 };
हर product अलग object, लेकिन class एक।
आप G17/S15 tracking server बना रहे हैं—
यहाँ हर device object होता है।
class GPSDevice
{
public string IMEI;
public double Latitude;
public double Longitude;
public int Battery;
public void UpdateLocation(double lat, double lon)
{
Latitude = lat;
Longitude = lon;
}
}
GPSDevice d = new GPSDevice();
d.IMEI = "861128068064267";
d.UpdateLocation(26.85, 80.94);
इसलिए 10,000 devices हों —
10,000 objects होंगे।
पर class एक ही!
Game में हर entity (Player, Enemy, Bullet) एक object होता है।
class Player
{
public int Health;
public void Jump() { }
public void Attack() { }
}
Game में 1 player + 20 enemies = multiple objects.
Class = Design
Object = Real Item
C# में हर चीज़ class/object पर बनी है।
Project जितना बड़ा, objects उतने ज्यादा।
आपने आज जो सीखा, उसी से बनता है:
Result System
Billing Software
GPS Trackers Database
E-Commerce Cart
Game Objects
ERP Systems
0 Comments
Thanks for Commenting on our blogs, we will revert back with answer of your query.
EmojiThanks & Regards
Sonu Yadav