Operator Overloading in c# ExampleIn this article, I am going to discuss about operator overloading and it's example, Sometimes developers confused about it and they think operator overloading and function overloading is same but both are very different.
Definition of Operator overloading
1. Operator overloading works on early binding approach.
2. We can't operator overload at that function which approaches decide at run-time.
Why we use operator overloading in c#Used for to achieve object addition.
Steps for implementing operator overloading in c#Here is some step that you need to follow while you are implementing operator overloading in c#.
1.The operator is a function is to be applied to support inbuilt operator to given an object
2.The opeartor function should be static(See Example).
3. This function always takes two parameters, can't have three parameters and must be public.
4.Note: We can't overload AND, OR, NOT like logical operator.
5. Operator function returns the object of containing class.
Example of Operator overloading
salary = 0;
public office(double sal)
salary = sal;
public void Display()
public static office operator +(office o,office ob) //it must be public static otherwise get compiler error
office obj = new office();
obj.salary = o.salary + ob.salary;
static void Main()
office a = new office(1212);
office b = new office(7888);
office accuntant = new office();
accuntant = a + b;
READ MORE-KNOW MORE