C#-এ ওভারলোডিং দুই ধরনের হয়।
ফাংশন ওভারলোডিং (Function Overloading)
একই স্কোপে একই ফাংশন নামের একাধিক সংজ্ঞা থাকতে পারে। ফাংশনের সংজ্ঞাগুলো আর্গুমেন্ট লিস্টে আর্গুমেন্টের টাইপ এবং/অথবা সংখ্যা অনুসারে একে অপরের থেকে আলাদা হতে হবে।
নিচে একটি উদাহরণ দেখি −
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) { }অপারেটর ওভারলোডিং (Operator Overloading)
ওভারলোডেড অপারেটরগুলি বিশেষ নাম সহ ফাংশন। operator কীওয়ার্ডের পর дефини করা অপারেটরের সিম্বল থাকে।
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; }