CharacterRange.Equality(CharacterRange, CharacterRange) Operador

Definición

Compara dos objetos CharacterRange. Obtiene un valor que indica si los valores de First y de Length de los dos objetos CharacterRange son iguales.

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

Parámetros

cr1
CharacterRange

Objeto CharacterRange que va a comparar para comprobar la igualdad.

cr2
CharacterRange

Objeto CharacterRange que va a comparar para comprobar la igualdad.

Devoluciones

Es true para indicar que los dos objetos CharacterRange tienen los mismos valores de First y de Length; de lo contrario, es false.

Ejemplos

En el ejemplo siguiente se muestra cómo usar el Equality operador . Para ejecutar este ejemplo, péguelo en un formulario Windows Forms. Controle el evento del Paint formulario y llame al CharacterRangeEquality1 método desde el Paint método de control de eventos, pasando e como 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

Comentarios

También puede probar la igualdad mediante el Equals método .

El método equivalente para este operador es CharacterRange.Equals(Object)

Se aplica a