语言

Rect.ToString 方法

定义

返回矩形的字符串表示形式。

重载

名称 说明
ToString()

返回矩形的字符串表示形式。

ToString(IFormatProvider)

使用指定的格式提供程序返回矩形的字符串表示形式。

ToString()

返回矩形的字符串表示形式。

public:
 override System::String ^ ToString();
public override string ToString();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

返回

当前矩形的字符串表示形式。 该字符串具有以下形式:“X,Y,WidthHeight”。

示例

以下示例演示如何使用 ToString() 该方法获取结构的字符串表示形式 Rect 。

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;
}

适用于

ToString(IFormatProvider)

使用指定的格式提供程序返回矩形的字符串表示形式。

public:
 System::String ^ ToString(IFormatProvider ^ provider);
public string ToString(IFormatProvider provider);
override this.ToString : IFormatProvider -> string
Public Function ToString (provider As IFormatProvider) As String

参数

provider
IFormatProvider

区域性特定的格式设置信息。

返回

由指定格式提供程序确定的当前矩形的字符串表示形式。

适用于