.NET interview questions: -Describe operator overloading?
- By Shiv Prasad Koirala in ASP.NET
- Sep 17th, 2011
- 30397
- 0
.NET interview questions: -Describe operator overloading?
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.
class SomeClassprivate int someValue;public SomeClass(int val)someValue = val; }public static SomeClass operator +(SomeClass arg1, SomeClass arg2)return new SomeClass(arg1.someValue + arg2.someValue);}}
You can now use the + operator to add objects of type someclass as shown in the below code snippet.
Obj = obj1 = obj2;
Also see the following private constructor video: -
interview questions and answers for .NET for preparation of real time interviews.
Regards,
Get more from author's blogs for Most asked .NET interview questions
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more

- By Shiv Prasad Koirala
- Jun 21st, 2013
- 163797
- 0
.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

- By Shiv Prasad Koirala
- Dec 8th, 2016
- 89165
- 0
Exception Handling in C# using example step by step

- By Shiv Prasad Koirala
- Sep 7th, 2013
- 72005
- 0