共用方式為


Size.Truncate(SizeF) 方法

定義

藉由將 SizeF 結構的值截斷為下一個較小的整數值,來將指定的 Size 結構轉換為 SizeF 結構。

public:
 static System::Drawing::Size Truncate(System::Drawing::SizeF value);
public static System.Drawing.Size Truncate (System.Drawing.SizeF value);
static member Truncate : System.Drawing.SizeF -> System.Drawing.Size
Public Shared Function Truncate (value As SizeF) As Size

參數

value
SizeF

要轉換的 SizeF 結構。

傳回

這個方法轉換成的 Size

範例

下列程式代碼範例示範如何使用靜態 Round 和方法,將轉換成 SizeFSizeTruncate 此範例的設計目的是要與 Windows Forms 搭配使用。 若要執行此範例,請將它貼到包含兩 Label 個名為 Label1Label2的物件表單中,然後從表單的建構函式呼叫這個方法。

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.Text = "Rounded size = "+roundedSize.ToString();
    Label2.Text = "Truncated size = "+truncatedSize.ToString();
}
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

適用於