CharacterRange.Inequality(CharacterRange, CharacterRange) Operátor

Definice

Porovná dva CharacterRange objekty. Získá hodnotu označující, zda First jsou hodnoty dvou LengthCharacterRange objektů nebo nerovny.

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

Parametry

cr1
CharacterRange

A CharacterRange pro porovnání nerovnosti.

cr2
CharacterRange

A CharacterRange pro porovnání nerovnosti.

Návraty

truek označení hodnot First nebo Length obou CharacterRange objektů se liší; v opačném případě . false

Příklady

Následující příklad ukazuje, jak použít metodu Inequality . Pokud chcete tento příklad spustit, vložte ho do formuláře Windows Form. Zpracování události formuláře Paint a volání CharacterRangeInequality metody z Paint metody zpracování událostí, předání e jako PaintEventArgs.

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

Poznámky

Metoda Inequality vrátí opak Equality metody.

Ekvivalentní metoda pro tento operátor je CharacterRange.Equals(Object)

Platí pro

Viz také