.NET interview questions: -Describe operator overloading?
- By Shiv Prasad Koirala in ASP.NET
- Sep 17th, 2011
- 17
- 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
- Sep 12th, 2013
- 428
- 0
What is Jquery ? ( ASP.NET Jquery interview questions with answers)
- By Shiv Prasad Koirala
- Jun 20th, 2012
- 152
- 0
C# threading interview questions: - What is the difference between
- By Shiv Prasad Koirala
- Feb 16th, 2013
- 105
- 0

