共用方式為


FontWeight.Compare(FontWeight, FontWeight) 方法

定義

比較兩個 FontWeight 執行個體。

public:
 static int Compare(System::Windows::FontWeight left, System::Windows::FontWeight right);
public static int Compare (System.Windows.FontWeight left, System.Windows.FontWeight right);
static member Compare : System.Windows.FontWeight * System.Windows.FontWeight -> int
Public Shared Function Compare (left As FontWeight, right As FontWeight) As Integer

參數

left
FontWeight

要比較的第一個 FontWeight 物件。

right
FontWeight

要比較的第二個 FontWeight 物件。

傳回

Int32

一個 Int32 值,表示兩個 FontWeight 執行個體之間的關聯性。 當傳回值小於零時,left 小於 right。 當此值為零時,即表示兩個運算元相等。 當此值大於零時,即表示 left 大於 right

範例

在下列程式碼範例中 Compare ,會使用 方法來評估兩個 FontWeight 物件。

// Return the typefaces for the selected font family name and font values.
Typeface typeface1 = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
Typeface typeface2 = new Typeface(new FontFamily("Arial"), FontStyles.Normal, FontWeights.UltraBold, FontStretches.Normal);

if (FontWeight.Compare(typeface1.Weight, typeface2.Weight) < 0)
{
    // Code execution follows this path because
    // the FontWeight of typeface1 (Normal) is less than of typeface2 (UltraBold).
}
' Return the typefaces for the selected font family name and font values.
Dim typeface1 As New Typeface(New FontFamily("Arial"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal)
Dim typeface2 As New Typeface(New FontFamily("Arial"), FontStyles.Normal, FontWeights.UltraBold, FontStretches.Normal)

If FontWeight.Compare(typeface1.Weight, typeface2.Weight) < 0 Then
    ' Code execution follows this path because
    ' the FontWeight of typeface1 (Normal) is less than of typeface2 (UltraBold).
End If

備註

較輕的字型粗細小於較重的字型粗細。 例如,「Light」 或 「Normal」 字型粗細小於 「UltraBold」 字型粗細。

適用於