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

注解

较轻的字体粗细小于更重的字体粗细。 例如,“浅色”或“普通”字体粗细小于“UltraBold”字体粗细。

适用于