String.Inequality(String, String) 연산자

정의

지정된 두 문자열의 값이 다른지를 확인합니다.

public:
 static bool operator !=(System::String ^ a, System::String ^ b);
public static bool operator != (string a, 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

매개 변수

a
String

비교할 첫 번째 문자열 또는 null입니다.

b
String

비교할 두 번째 문자열 또는 null입니다.

반환

true의 값이 a의 값과 다르면 b이고, 그러지 않으면 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
*/
// 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.
printfn "This example of the String Inequality operator\ngenerates the following output.\n"

let compareAndDisplay comparand =
    let lower = "abcd"
    printfn $"\"%s{lower}\" <> \"%s{comparand}\" ?  {lower <> comparand}"

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
*)

설명

메서드는 Inequality 클래스에 대한 같지 않음 연산자의 연산을 정의합니다 String . 예제 섹션에 표시된 것과 같은 코드를 사용하도록 설정합니다.

연산자는 Inequality 정적 Equals(String, String) 메서드를 호출하여 서수(대/소문자를 구분하고 문화권을 구분하지 않음) 비교를 수행합니다.

참고

Visual Basic 컴파일러는 같지 않음 연산자를 메서드에 대한 호출 Inequality 로 해결하지 않습니다. 대신 같지 않음 연산자는 메서드에 대한 호출을 Operators.CompareString 래핑합니다.

적용 대상