C# এ ওভারলোডিং দুই প্রকার।
ফাংশন ওভারলোডিং
একই সুযোগে একই ফাংশনের নামের জন্য আপনার একাধিক সংজ্ঞা থাকতে পারে। ফাংশনের সংজ্ঞাটি আর্গুমেন্ট তালিকার প্রকার এবং/অথবা আর্গুমেন্টের সংখ্যা দ্বারা একে অপরের থেকে আলাদা হতে হবে।
আসুন একটি উদাহরণ দেখি -
public static int mulDisplay(int one, int two) { }
public static int mulDisplay(int one, int two, int three) { }
public static int mulDisplay(int one, int two, int three, int four) { } অপারেটর ওভারলোডিং
ওভারলোডেড অপারেটর হল বিশেষ নামের ফাংশন। কীওয়ার্ড অপারেটরকে সংজ্ঞায়িত করা অপারেটরের প্রতীক দ্বারা অনুসরণ করা হয়।
public static Box operator+ (Box b, Box c) {
Box box = new Box();
box.length = b.length + c.length;
box.breadth = b.breadth + c.breadth;
box.height = b.height + c.height;
return box;
}