Rect.ToString 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳矩形的字串表示。
多載
| 名稱 | Description |
|---|---|
| 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
文化特定的格式資訊。
傳回
由指定格式提供者決定的當前矩形的字串表示。