How to convert a rectangle to RectangleF?

What is the easiest way to convert Rectanglein RectangleFin .NET?

Edit: This sounds trivial, and it does, but I tried to preserve some typing. The best I could come up with:

RectangleF rdest(rsrc.Location, rsrc.Size); // C++/CLI

... or...

RectangleF rdest = new RectangleF(rsrc.Location, rsrc.Size) // C#
+5
source share
1 answer

There is an implicit converter, so you can just do:

RectangleF rectanglef = rectangle;

http://msdn.microsoft.com/en-us/library/system.drawing.rectanglef.op_implicit.aspx

In fact, you already knew that: it will easily skip, but your code uses two such implicit translations - you use Pointand Size, where should be PointFand SizeF.

+12
source

All Articles