Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CharacterRange.Equality Operator

Compares two CharacterRange objects. Gets a value indicating whether the First and Length values of the two CharacterRange objects are equal.

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

public static bool operator ==(
	CharacterRange cr1,
	CharacterRange cr2
)

Parameters

cr1
Type: System.Drawing.CharacterRange

A CharacterRange to compare for equality.

cr2
Type: System.Drawing.CharacterRange

A CharacterRange to compare for equality.

Return Value

Type: System.Boolean
true to indicate the two CharacterRange objects have the same First and Length values; otherwise, false.

You can also test for equality using the Equals method.

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

private void CharacterRangeEquality1()
{

    // 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 == range2)
        MessageBox.Show("The ranges are equal.");
    else
        MessageBox.Show("The ranges are not equal.");

}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft