If I do this:
Rect rc = new Rect(0, 0, 10, 5);
I am creating a rectangle at position 0, 0 with a width of 10 and height of 5.
So rc.Width is 10 and rc.Heightis 5.
But how come rc.Right is 9 instead of 10 and rc.Bottom is 5 instead of 4?
EDIT: Actually, Rect also works as you expect, I tried in Visual Studio 2017:

Are you using some other Rect? Below is decompiled code for calculating Bottom:
/// <summary>
/// Bottom Property - This is a read-only alias for Y + Height
/// If this is the empty rectangle, the value will be negative infinity.
/// </summary>
public double Bottom
{
get
{
if (IsEmpty)
{
return Double.NegativeInfinity;
}
return _y + _height; //notice it's just top + height, no magic
}
}
Old answer - Use Rectangle. It works as you expect:
Rectangle rc = new Rectangle(0, 0, 10, 5);

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With