共用方式為


CharacterRange.Equals 方法

定義

多載

Equals(CharacterRange)

指出目前的實例是否等於相同類型的另一個實例。

Equals(Object)

取得值,指出此物件是否相當於指定的物件。

Equals(CharacterRange)

來源:
CharacterRange.cs
來源:
CharacterRange.cs
來源:
CharacterRange.cs

指出目前的實例是否等於相同類型的另一個實例。

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

參數

other
CharacterRange

要與此實例比較的實例。

傳回

true 如果目前的實例等於其他實例,則為 ;否則為 false

實作

適用於

Equals(Object)

來源:
CharacterRange.cs
來源:
CharacterRange.cs
來源:
CharacterRange.cs

取得值,指出此物件是否相當於指定的物件。

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

參數

obj
Object

要比較是否相等的物件。

傳回

true 表示指定的物件是與這個執行個體具有相同 FirstLength 值的執行個體,否則為 false

範例

下列範例示範如何使用 Equals 方法。 若要執行此範例,請將它貼到 Windows Form 中。 處理表單的事件 Paint ,並從事件處理方法呼叫 CharacterRangeEquality2 方法 Paint ,並傳遞 ePaintEventArgs

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

備註

您也可以使用 Equality 來測試是否相等。

適用於