1. Back To Blog

C#/.NET interview questions: - What is operator overloading? Mention differences between overloading and overriding?

Operator overloading is a concept of polymorphism where you can redefine operators like +, - , * etc with additional functionalities.


For instance we can redefine the + functionalities to add objects like obj1 + obj2. Below is simple code snippet which redefines + operator.




You can now use the + operator to add objects of type some class as shown in the below code snippet.




Differences between overloading and overriding


Overloading

Overriding

Overloading is a concept where we can have same method names with different input signature.

In overriding we have a parent class with virtual functions which are overridden in the child classes.


Also see the following .NET interview questions video on operator overloading in C# (Csharp): -


Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social