Skip to main content
.NET Framework Class Library
RectangleF Structure

Stores a set of four floating-point numbers that represent the location and size of a rectangle. For more advanced region functions, use a Region object.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
Syntax
<[%$TOPIC/kwafa1d7_en-us_VS_110_2_0_0_0_0%]> _
Public Structure RectangleF
[[%$TOPIC/kwafa1d7_en-us_VS_110_2_0_1_0_0%]]
public struct RectangleF
[[%$TOPIC/kwafa1d7_en-us_VS_110_2_0_2_0_0%]]
public value class RectangleF
[<[%$TOPIC/kwafa1d7_en-us_VS_110_2_0_3_0_0%]>]
[<[%$TOPIC/kwafa1d7_en-us_VS_110_2_0_3_0_1%]>]
type RectangleF =  struct end

The RectangleF type exposes the following members.

Constructors
  NameDescription
Public method RectangleF(PointF, SizeF)Initializes a new instance of the RectangleF class with the specified location and size.
Public method RectangleF(Single, Single, Single, Single)Initializes a new instance of the RectangleF class with the specified location and size.
Top
Properties
  NameDescription
Public property BottomGets the y-coordinate that is the sum of Y and Height of this RectangleF structure.
Public property HeightGets or sets the height of this RectangleF structure.
Public property IsEmptyTests whether the Width or Height property of this RectangleF has a value of zero.
Public property LeftGets the x-coordinate of the left edge of this RectangleF structure.
Public property LocationGets or sets the coordinates of the upper-left corner of this RectangleF structure.
Public property RightGets the x-coordinate that is the sum of X and Width of this RectangleF structure.
Public property SizeGets or sets the size of this RectangleF.
Public property TopGets the y-coordinate of the top edge of this RectangleF structure.
Public property WidthGets or sets the width of this RectangleF structure.
Public property XGets or sets the x-coordinate of the upper-left corner of this RectangleF structure.
Public property YGets or sets the y-coordinate of the upper-left corner of this RectangleF structure.
Top
Methods
  NameDescription
Public method Contains(PointF)Determines if the specified point is contained within this RectangleF structure.
Public method Contains(RectangleF)Determines if the rectangular region represented by rect is entirely contained within this RectangleF structure.
Public method Contains(Single, Single)Determines if the specified point is contained within this RectangleF structure.
Public method EqualsTests whether obj is a RectangleF with the same location and size of this RectangleF. (Overrides ValueTypeEquals(Object).)
Public method Static member FromLTRBCreates a RectangleF structure with upper-left corner and lower-right corner at the specified locations.
Public method GetHashCodeGets the hash code for this RectangleF structure. For information about the use of hash codes, see Object.GetHashCode. (Overrides ValueTypeGetHashCode.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method Inflate(SizeF)Enlarges this RectangleF by the specified amount.
Public method Inflate(Single, Single)Enlarges this RectangleF structure by the specified amount.
Public method Static member Inflate(RectangleF, Single, Single)Creates and returns an enlarged copy of the specified RectangleF structure. The copy is enlarged by the specified amount and the original rectangle remains unmodified.
Public method Intersect(RectangleF)Replaces this RectangleF structure with the intersection of itself and the specified RectangleF structure.
Public method Static member Intersect(RectangleF, RectangleF)Returns a RectangleF structure that represents the intersection of two rectangles. If there is no intersection, and empty RectangleF is returned.
Public method IntersectsWithDetermines if this rectangle intersects with rect.
Public method Offset(PointF)Adjusts the location of this rectangle by the specified amount.
Public method Offset(Single, Single)Adjusts the location of this rectangle by the specified amount.
Public method ToStringConverts the Location and Size of this RectangleF to a human-readable string. (Overrides ValueTypeToString.)
Public method Static member UnionCreates the smallest possible third rectangle that can contain both of two rectangles that form a union.
Top
Operators
  NameDescription
Public operator Static member EqualityTests whether two RectangleF structures have equal location and size.
Public operator Static member (Rectangle to RectangleF)Converts the specified Rectangle structure to a RectangleF structure.
Public operator Static member InequalityTests whether two RectangleF structures differ in location or size.
Top
Fields
  NameDescription
Public field Static member EmptyRepresents an instance of the RectangleF class with its members uninitialized.
Top
Remarks

A rectangle is defined by its width, height, and upper-left corner.

Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.