CharacterRange.Equals 方法

定义

重载

Equals(CharacterRange)

指示当前实例是否等于同一类型的另一个实例。

Equals(Object)

获取指示此对象是否与指定对象等效的值。

Equals(CharacterRange)

Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
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)

Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
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

要进行等效性比较的对象。

返回

如果指定对象是与此实例具有相同的 FirstLength 值的实例,则为 true;否则为 false

示例

下面的示例演示如何使用 Equals 方法。 若要运行此示例,请将其粘贴到 Windows 窗体中。 处理窗体的 Paint 事件,并从Paint事件处理方法调用 CharacterRangeEquality2 方法,作为 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 来测试相等性。

适用于