Overriding the + and – operators in C# .NET
December 18, 2015 Leave a comment
It’s easy to override the mathemtical operators like + or – in C# to build custom operations.
Consider the following simple Rectangle class:
public class Rectangle
{
public Rectangle(int width, int height)
{
Height = height;
Width = width;
}
public int Width
{
get;
set;
}
public int Height
{
get;
set;
}
}