CharacterRange.Inequality Operator (CharacterRange, CharacterRange)

 
equivalentCodeEntityM:System.Drawing.CharacterRange.Compare(System.Drawing.CharacterRange,System.Drawing.CharacterRange)

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
)

Parameters

cr1
Type: System.Drawing.CharacterRange

A CharacterRange to compare for inequality.

cr2
Type: System.Drawing.CharacterRange

A CharacterRange to compare for inequality.

Return Value

Type: System.Boolean

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

The Inequality method returns the opposite of the Equality method.

The following example demonstrates how to use the 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.");
    else
        MessageBox.Show("The ranges are equal.");
}

.NET Framework
Available since 2.0
Return to top
Show: