CharacterRange.Equals Metoda

Definice

Přetížení

Equals(CharacterRange)

Určuje, zda je aktuální instance rovna jiné instanci stejného typu.

Equals(Object)

Získá hodnotu označující, zda je tento objekt ekvivalentní zadanému objektu.

Equals(CharacterRange)

Zdroj:
CharacterRange.cs
Zdroj:
CharacterRange.cs
Zdroj:
CharacterRange.cs

Určuje, zda je aktuální instance rovna jiné instanci stejného typu.

public:
 virtual bool Equals(System::Drawing::CharacterRange other);
public bool Equals (System.Drawing.CharacterRange other);
public readonly bool Equals (System.Drawing.CharacterRange other);
override this.Equals : System.Drawing.CharacterRange -> bool
Public Function Equals (other As CharacterRange) As Boolean

Parametry

other
CharacterRange

Instance, která se má porovnat s touto instancí.

Návraty

truePokud je aktuální instance rovna druhé instanci; v opačném případě . false

Implementuje

Platí pro

Equals(Object)

Zdroj:
CharacterRange.cs
Zdroj:
CharacterRange.cs
Zdroj:
CharacterRange.cs

Získá hodnotu označující, zda je tento objekt ekvivalentní zadanému objektu.

public:
 override bool Equals(System::Object ^ obj);
public override bool Equals (object obj);
public override bool Equals (object? obj);
public override readonly bool Equals (object? obj);
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean

Parametry

obj
Object

Objekt, se který se má porovnat s z důvodu rovnosti.

Návraty

true k označení, že zadaný objekt je instance se stejnou First hodnotou a Length jako tato instance; v opačném případě false.

Příklady

Následující příklad ukazuje, jak použít metodu Equals . Pokud chcete spustit tento příklad, vložte ho do formuláře Windows Form. Zpracujte Paint událost formuláře a zavolejte metodu CharacterRangeEquality2Paint z metody zpracování událostí a předejte e ji jako PaintEventArgs.

private void CharacterRangeEquality2()
{

    // 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.Equals(range2))
        MessageBox.Show("The ranges are equal.");
    else
        MessageBox.Show("The ranges are not equal.");
}
Private Sub CharacterRangeEquality2() 
    
    ' 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.Equals(range2) Then
        MessageBox.Show("The ranges are equal.")
    Else
        MessageBox.Show("The ranges are not equal.")
    End If
 
End Sub

Poznámky

Můžete také použít Equality k testování rovnosti.

Platí pro