# String.Inequality(String, String) Opérateur

## Définition

Détermine si deux chaînes spécifiées ont des valeurs différentes.Determines whether two specified strings have different values.

``````public:
static bool operator !=(System::String ^ a, System::String ^ b);``````
``public static bool operator != (string a, string b);``
``static member op_Inequality : string * string -> bool``
``Public Shared Operator != (a As String, b As String) As Boolean``

#### Paramètres

a
String

Première chaîne à comparer, ou `null`.The first string to compare, or `null`.

b
String

Deuxième chaîne à comparer, ou `null`.The second string to compare, or `null`.

#### Retours

`true` si la valeur de `a` est différente de la valeur de `b` ; sinon, `false`.`true` if the value of `a` is different from the value of `b`; otherwise, `false`.

## Exemples

L’exemple suivant illustre l’opérateur d’inégalité.The following example demonstrates the inequality operator.

``````// 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
*/
``````
``````// 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
*/
``````

## Remarques

La méthode Inequality définit l’opération de l’opérateur d’inégalité pour la classe String.The Inequality method defines the operation of the inequality operator for the String class. Il active le code tel que celui indiqué dans la section exemples.It enables code such as that shown in the Examples section.

L’opérateur Inequality appelle à son tour la méthode statique Equals(String, String), qui effectue une comparaison ordinale (respectant la casse et non-respect de la culture).The Inequality operator in turn calls the static Equals(String, String) method, which performs an ordinal (case-sensitive and culture-insensitive) comparison.

Notes

Le compilateur Visual Basic ne résout pas l’opérateur d’inégalité comme un appel à la méthode Inequality.The Visual Basic compiler does not resolve the inequality operator as a call to the Inequality method. À la place, l’opérateur d’inégalité encapsule un appel à la méthode Operators.CompareString.Instead, the inequality operator wraps a call to the Operators.CompareString method.