Rect.ToString Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a string representation of the rectangle.
Overloads
ToString() |
Returns a string representation of the rectangle. |
ToString(IFormatProvider) |
Returns a string representation of the rectangle by using the specified format provider. |
ToString()
Returns a string representation of the rectangle.
public:
override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String
Returns
A string representation of the current rectangle. The string has the following form: "X,Y,Width,Height".
Examples
The following example shows how to use the ToString() method to get a string representation of a Rect structure.
private string toStringExample()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Get a string representation of a Rect structure.
// rectString is equal to "10,5,200,50" .
string rectString = myRectangle.ToString();
return rectString;
}
Applies to
ToString(IFormatProvider)
Returns a string representation of the rectangle by using the specified format provider.
public:
System::String ^ ToString(IFormatProvider ^ provider);
public string ToString (IFormatProvider provider);
override this.ToString : IFormatProvider -> string
Public Function ToString (provider As IFormatProvider) As String
Parameters
- provider
- IFormatProvider
Culture-specific formatting information.
Returns
A string representation of the current rectangle that is determined by the specified format provider.