Export (0) Print
Expand All

CharacterRange.Equals Method

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

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

public override bool Equals(
	Object obj
)

Parameters

obj
Type: System.Object

The object to compare to for equality.

Return Value

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

You can also use Equality to test for equality.

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.

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

}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft