This documentation is archived and is not being maintained.

CharacterRange.op_Inequality Method

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

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

public static bool operator != (
	CharacterRange cr1,
	CharacterRange cr2
Not applicable.



A CharacterRange to compare for inequality.


A CharacterRange to compare for inequality.

Return Value

true to indicate the either the First or Length values of the two CharacterRange objects differ; otherwise, false.

The op_Inequality method returns the opposite of the op_Equality method.

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

private void CharacterRangeInequality()

    // 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("string"), "strings".Length);

    if (range1 != range2)
        MessageBox.Show("The ranges are not equal.");
        MessageBox.Show("The ranges are equal.");

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0