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 表示兩個實例 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」字型粗細小。

適用於