Skip to content

The Rectangle.Union remarks indicate a behavior that is not seen and unreasonable.Β #11633

@otac0n

Description

@otac0n

Type of issue

Crazy, Incorrect Remarks

Description

The remarks are incorrect and would be very weird if they were correct.

🚧 THE REMARKS SHOULD BE REMOVED. 🚧

The remarks state:

When one of the two rectangles is empty, meaning all of its values are zero, the Union method returns a rectangle with a starting point of (0, 0), and the height and width of the non-empty rectangle. For example, if you have two rectangles: A = (0, 0; 0, 0) and B = (1, 1; 2, 2), then the union of A and B is (0, 0; 2, 2).

However, using the exact values from the remarks does not give the value promised.

// Declare two rectangles and draw them.
var rectangle1 = new Rectangle(0, 0, 0, 0);
var rectangle2 = new Rectangle(1, 1, 2, 2);
g.DrawRectangle(Pens.Sienna, rectangle1);
g.DrawRectangle(Pens.BlueViolet, rectangle2);

// Declare a third rectangle as a union of the first two.
var rectangle3 = Rectangle.Union(rectangle1, rectangle2).Dump();

Result:

{X=0,Y=0,Width=3,Height=3}

🚧 THIS IS CORRECT AND REASONABLE. THE REMARKS ARE UNNECESSARY AND INCORRECT. 🚧

Image

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.drawing.rectangle.union?view=net-9.0&devlangs=csharp&f1url=%3FappId%3DDev17IDEF1%26l%3DEN-US%26k%3Dk(System.Drawing.Rectangle.Union)%3Bk(DevLang-csharp)%26rd%3Dtrue

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Drawing/Rectangle.xml

Document Version Independent Id

71367ba3-b782-10ab-e718-4151739eaafa

Platform Id

5aef8bd6-6060-ace5-8d11-a512d660587e

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions