Size.Round-Methode
Konvertiert die angegebene SizeF-Struktur in eine Size-Struktur, indem die Werte der SizeF-Struktur auf die nächsten ganzzahligen Werte gerundet werden.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Syntax
'Declaration
Public Shared Function Round ( _
value As SizeF _
) As Size
'Usage
Dim value As SizeF
Dim returnValue As Size
returnValue = Size.Round(value)
public static Size Round (
SizeF value
)
public:
static Size Round (
SizeF value
)
public static Size Round (
SizeF value
)
public static function Round (
value : SizeF
) : Size
Parameter
- value
Die zu konvertierende SizeF-Struktur.
Rückgabewert
Die Size-Struktur, in die diese Methode konvertiert.
Beispiel
Im folgenden Codebeispiel wird veranschaulicht, wie die statische Round-Methode und Truncate-Methode verwendet werden, um eine SizeF in eine Size zu konvertieren. Dieses Beispiel ist für die Verwendung mit Windows Forms vorgesehen. Um dieses Beispiel auszuführen, fügen Sie es in ein Formular ein, das zwei Label-Objekte mit den Namen Label1
und Label2
enthält, und rufen Sie dann diese Methode im Konstruktor des Formulars auf.
Private Sub TruncateAndRoundSizes()
' Create a SizeF.
Dim theSize As New SizeF(75.9, 75.9)
' Round the Size.
Dim roundedSize As Size = Size.Round(theSize)
' Truncate the Size.
Dim truncatedSize As Size = Size.Truncate(theSize)
'Print out the values on two labels.
Label1.Text = "Rounded size = " & roundedSize.ToString()
Label2.Text = "Truncated size = " & truncatedSize.ToString
End Sub
private void TruncateAndRoundSizes()
{
// Create a SizeF.
SizeF theSize = new SizeF(75.9F, 75.9F);
// Round the Size.
Size roundedSize = Size.Round(theSize);
// Truncate the Size.
Size truncatedSize = Size.Truncate(theSize);
//Print out the values on two labels.
Label1.Text = "Rounded size = "+roundedSize.ToString();
Label2.Text = "Truncated size = "+truncatedSize.ToString();
}
void TruncateAndRoundSizes()
{
// Create a SizeF.
SizeF theSize = SizeF(75.9F,75.9F);
// Round the Size.
System::Drawing::Size roundedSize = ::Size::Round( theSize );
// Truncate the Size.
System::Drawing::Size truncatedSize = ::Size::Truncate( theSize );
//Print out the values on two labels.
Label1->Text = String::Format( "Rounded size = {0}", roundedSize );
Label2->Text = String::Format( "Truncated size = {0}", truncatedSize );
}
private void TruncateAndRoundSizes()
{
// Create a SizeF.
SizeF theSize = new SizeF(75.9F, 75.9F);
// Round the Size.
Size roundedSize = Size.Round(theSize);
// Truncate the Size.
Size truncatedSize = Size.Truncate(theSize);
//Print out the values on two labels.
label1.set_Text("Rounded size = " + roundedSize.ToString());
label2.set_Text("Truncated size = " + truncatedSize.ToString());
} //TruncateAndRoundSizes
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0