Прочитај на енглеском Уреди

Делите путем


CharacterRange.Equals Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Equals(CharacterRange)

Indicates whether the current instance is equal to another instance of the same type.

Equals(Object)

Gets a value indicating whether this object is equivalent to the specified object.

Equals(CharacterRange)

Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs

Indicates whether the current instance is equal to another instance of the same type.

C#
public readonly bool Equals(System.Drawing.CharacterRange other);
C#
public bool Equals(System.Drawing.CharacterRange other);

Parameters

other
CharacterRange

An instance to compare with this instance.

Returns

true if the current instance is equal to the other instance; otherwise, false.

Implements

Applies to

.NET 10 (package-provided) и друге верзије
Производ Верзије
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
Windows Desktop 7, 8, 9, 10

Equals(Object)

Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs
Source:
CharacterRange.cs

Gets a value indicating whether this object is equivalent to the specified object.

C#
public override readonly bool Equals(object? obj);
C#
public override bool Equals(object obj);
C#
public override bool Equals(object? obj);

Parameters

obj
Object

The object to compare to for equality.

Returns

true to indicate the specified object is an instance with the same First and Length value as this instance; otherwise, false.

Examples

The following example demonstrates how to use the Equals method. To run this example, paste it into a Windows Form. Handle the form's Paint event and call the CharacterRangeEquality2 method from the Paint event-handling method, passing e as PaintEventArgs.

C#
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.");
}

Remarks

You can also use Equality to test for equality.

Applies to

.NET 10 (package-provided) и друге верзије
Производ Верзије
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10