Tell us what is Operator Overloading and how does it work?
Submitted by: MuhammadMost of the built-in operators available in C# can be overloaded or redefined using the operator keyword. The sample code below depicts the syntax used to implement the addition operator (+) for a user-defined class.
public static Rectangle operator+ (Rectangle b, Rectangle c)
{
Rectangle rectangle = new Rectangle();
rectangle.length = b.length + c.length;
rectangle.breadth = b.breadth + c.breadth;
rectangle.height = b.height + c.height;
return rectangle;
}
Submitted by: Muhammad
public static Rectangle operator+ (Rectangle b, Rectangle c)
{
Rectangle rectangle = new Rectangle();
rectangle.length = b.length + c.length;
rectangle.breadth = b.breadth + c.breadth;
rectangle.height = b.height + c.height;
return rectangle;
}
Submitted by: Muhammad
Read Online Unity Developer Job Interview Questions And Answers
Top Unity Developer Questions
☺ | Tell us what Pricing Model Do You Use? |
☺ | Please tell us what are your lifelong dreams? |
☺ | Tell me the basic construction of a C# program. Write a simple program that outputs “Hello World” to the console? |
☺ | Explain me how does C# handle encapsulation? |
☺ | Tell me how articulate are you in expressing your ideas? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |