
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Overloading in C#
Overloading is of two types in C#.
Function Overloading
You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list.
Let us see an example −
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
Overloaded operators are functions with special names. The keyword operator is followed by the symbol for the operator being defined.
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; }
- Related Articles
- Constructor Overloading in C#
- Constructor Overloading in C++
- Overloading unary operators + in C++
- Overloading unary operator in C++?
- What is overloading in C#?
- What is method overloading in C#?
- Overloading stream insertion () operators in C++
- Rules for operator overloading in C++
- Overloading array index operator [] in C++
- Increment ++ and Decrement -- Operator Overloading in C++
- How to use Operator Overloading in C#?
- How to implement operator overloading in C#?
- Function overloading and const keyword in C++
- Function overloading and return type in C++
- What is overloading a unary operator in C++?

Advertisements