CharacterRange.Equality(CharacterRange, CharacterRange) CharacterRange.Equality(CharacterRange, CharacterRange) CharacterRange.Equality(CharacterRange, CharacterRange) CharacterRange.Equality(CharacterRange, CharacterRange) Operator

Définition

Compare deux objets CharacterRange.Compares two CharacterRange objects. Obtient une valeur indiquant si les valeurs First et Length des deux objets CharacterRange sont égales.Gets a value indicating whether the First and Length values of the two CharacterRange objects are equal.

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 ( = ) : System.Drawing.CharacterRange * System.Drawing.CharacterRange -> bool
Public Shared Operator == (cr1 As CharacterRange, cr2 As CharacterRange) As Boolean

Paramètres

cr1
CharacterRange CharacterRange CharacterRange CharacterRange

CharacterRange à comparer en termes d'égalité.A CharacterRange to compare for equality.

cr2
CharacterRange CharacterRange CharacterRange CharacterRange

CharacterRange à comparer en termes d'égalité.A CharacterRange to compare for equality.

Retours

true pour indiquer que les deux objets CharacterRange ont les mêmes valeurs First et Length ; sinon, false.true to indicate the two CharacterRange objects have the same First and Length values; otherwise, false.

Exemples

L’exemple suivant montre comment utiliser l' Equality opérateur.The following example demonstrates how to use the Equality operator. Pour exécuter cet exemple, collez-le dans un Windows Form.To run this example, paste it into a Windows Form. Gérez l’événement du Paint formulaire et appelez la CharacterRangeEquality1 méthode à partir Paint de la méthode de gestion des e événements PaintEventArgs, en passant comme.Handle the form's Paint event and call the CharacterRangeEquality1 method from the Paint event-handling method, passing e as PaintEventArgs.

    private void CharacterRangeEquality1()
    {

        // 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("strings"), "strings".Length);

        if (range1 == range2)
            MessageBox.Show("The ranges are equal.");
        else
            MessageBox.Show("The ranges are not equal.");

    }
Private Sub CharacterRangeEquality1() 
    
    ' 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("strings"), _
        "strings".Length)
    
    If range1 = range2 Then
        MessageBox.Show("The ranges are equal.")
    Else
        MessageBox.Show("The ranges are not equal.")
    End If
 
End Sub

Remarques

Vous pouvez également tester l’égalité à l' Equals aide de la méthode.You can also test for equality using the Equals method.

La méthode équivalente pour cet opérateur estCharacterRange.Equals(Object)The equivalent method for this operator is CharacterRange.Equals(Object)

S’applique à