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,Width,Height"。

範例

下列範例示範如何使用 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

文化特性 (Culture) 特有的格式資訊。

傳回

目前矩形的字串表示,透過指定的格式提供者進行判斷。

適用於