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

Делите путем


CharacterRange.Inequality(CharacterRange, CharacterRange) Operator

Definition

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

C#
public static bool operator !=(System.Drawing.CharacterRange cr1, System.Drawing.CharacterRange cr2);

Parameters

cr1
CharacterRange

A CharacterRange to compare for inequality.

cr2
CharacterRange

A CharacterRange to compare for inequality.

Returns

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

Examples

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.

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

Remarks

The Inequality method returns the opposite of the Equality method.

The equivalent method for this operator is CharacterRange.Equals(Object)

Applies to

Производ Верзије
.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

See also