CharacterRange.Inequality(CharacterRange, CharacterRange) 运算符

定义

比较两个 CharacterRange 对象。 指示两个 CharacterRange 对象的 FirstLength 值是否不等的值。

public:
 static bool operator !=(System::Drawing::CharacterRange cr1, System::Drawing::CharacterRange cr2);
public static bool operator != (System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2);
static member op_Inequality : System.Drawing.CharacterRange * System.Drawing.CharacterRange -> bool
Public Shared Operator != (cr1 As CharacterRange, cr2 As CharacterRange) As Boolean

参数

cr1
CharacterRange

要比较不等性的 CharacterRange

cr2
CharacterRange

要比较不等性的 CharacterRange

返回

如果两个 CharacterRange 对象的 FirstLength 值中的任一个不同,为 true;否则为 false

示例

下面的示例演示如何使用 Inequality 方法。 若要运行此示例,请将其粘贴到 Windows 窗体中。 处理窗体的事件Paint,并从Paint事件处理方法调用 CharacterRangeInequality 方法,作为 ePaintEventArgs传递。

private void CharacterRangeInequality()
{

    // Declare the string to draw.
    string message = "Strings or strings; that is the question.";

    // Compare the ranges for equality. The should not be equal.
    CharacterRange range1 =
        new CharacterRange(message.IndexOf("Strings"), "Strings".Length);
    CharacterRange range2 =
        new CharacterRange(message.IndexOf("string"), "strings".Length);

    if (range1 != range2)
        MessageBox.Show("The ranges are not equal.");
    else
        MessageBox.Show("The ranges are equal.");
}
Private Sub CharacterRangeInequality() 
    
    ' Declare the string to draw.
    Dim message As String = "Strings or strings; that is the question."
    
    ' Compare the ranges for equality. The should not be equal.
    Dim range1 As New CharacterRange(message.IndexOf("Strings"), "Strings".Length)
    Dim range2 As New CharacterRange(message.IndexOf("string"), "strings".Length)
    
    If range1 <> range2 Then
        MessageBox.Show("The ranges are not equal.")
    Else
        MessageBox.Show("The ranges are equal.")
    End If
End Sub

注解

方法 Inequality 返回 与 方法相反的 Equality

此运算符的等效方法是 CharacterRange.Equals(Object)

适用于

另请参阅