Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Rect.ToString Method ()

Creates a String representation of the current rectangle.

Namespace: System.Windows
Assembly: WindowsBase (in windowsbase.dll)

public override string ToString ()
public String ToString ()
public override function ToString () : String
You cannot use methods in XAML.

Return Value

A String representation of the current rectangle. The string has the following form: X,Y,Width,Height.

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;

}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.