Skip to main content
.NET Framework Class Library
StringInequality Operator

Determines whether two specified strings have different values.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)
Syntax
Public Shared Operator <> ( _
	a As [%$TOPIC/w6xe49wf_en-us_VS_110_1_0_0_0_0%], _
	b As [%$TOPIC/w6xe49wf_en-us_VS_110_1_0_0_0_1%] _
) As [%$TOPIC/w6xe49wf_en-us_VS_110_1_0_0_0_2%]
public static [%$TOPIC/w6xe49wf_en-us_VS_110_1_0_1_0_0%] operator !=(
	[%$TOPIC/w6xe49wf_en-us_VS_110_1_0_1_0_1%] a,
	[%$TOPIC/w6xe49wf_en-us_VS_110_1_0_1_0_2%] b
)
public:
static [%$TOPIC/w6xe49wf_en-us_VS_110_1_0_2_0_0%] operator !=(
	[%$TOPIC/w6xe49wf_en-us_VS_110_1_0_2_0_1%]^ a, 
	[%$TOPIC/w6xe49wf_en-us_VS_110_1_0_2_0_2%]^ b
)
static let inline(<>)
        a:[%$TOPIC/w6xe49wf_en-us_VS_110_1_0_3_0_0%] * 
        b:[%$TOPIC/w6xe49wf_en-us_VS_110_1_0_3_0_1%]  : [%$TOPIC/w6xe49wf_en-us_VS_110_1_0_3_0_2%]
JScript does not support overloaded operators.

Parameters

a
Type: SystemString

The first string to compare, or .

b
Type: SystemString

The second string to compare, or .

Return Value

Type: SystemBoolean
true if the value of a is different from the value of b; otherwise, false.
Remarks

The Inequality method defines the operation of the inequality operator for the String class.

This operator is implemented using the Equals method, which means the comparands are tested for a combination of reference and value equality. This operator performs an ordinal comparison.

NoteNote

   The Visual Basic compiler does not resolve the inequality operator as a call to the Inequality method. Instead, the inequality operator wraps a call to the OperatorsCompareString method.

Examples

The following example demonstrates the inequality operator.

// Example for the String Inequality operator. 
using System;

class InequalityOp 
{
    public static void Main() 
    {
        Console.WriteLine( 
            "This example of the String Inequality operator\n" +
            "generates the following output.\n" );

        CompareAndDisplay( "ijkl" );
        CompareAndDisplay( "ABCD" );
        CompareAndDisplay( "abcd" );
    }

    static void CompareAndDisplay( String Comparand )
    {
        String  Lower = "abcd";

        Console.WriteLine( 
            "\"{0}\" != \"{1}\" ?  {2}",
            Lower, Comparand, Lower != Comparand );
    }
}

/*
This example of the String Inequality operator
generates the following output.

"abcd" != "ijkl" ?  True
"abcd" != "ABCD" ?  True
"abcd" != "abcd" ?  False
*/
// Example for the String Inequality operator. 
using namespace System;
void CompareAndDisplay( String^ Comparand )
{
   String^ Lower = "abcd";
   Console::WriteLine( "\"{0}\" != \"{1}\" ?  {2}", Lower, Comparand, Lower != Comparand );
}

int main()
{
   Console::WriteLine( "This example of the String Inequality operator\n" 
   "generates the following output.\n" );
   CompareAndDisplay( "ijkl" );
   CompareAndDisplay( "ABCD" );
   CompareAndDisplay( "abcd" );
}

/*
This example of the String Inequality operator
generates the following output.

"abcd" != "ijkl" ?  True
"abcd" != "ABCD" ?  True
"abcd" != "abcd" ?  False
*/
Version Information

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8