String.Equality(String, String) 연산자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 두 문자열의 값이 같은지 여부를 확인합니다.
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 ( = ) : string * string -> bool
Public Shared Operator == (a As String, b As String) As Boolean
매개 변수
- a
- String
비교할 첫 번째 문자열 또는 null.
- b
- String
비교할 두 번째 문자열 또는 null.
반품
예제
다음 예제에서는 같음 연산자를 보여 줍니다.
// Example for the String Equality operator.
using System;
class EqualityOp
{
public static void Main()
{
Console.WriteLine(
"This example of the String Equality 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 Equality operator
generates the following output.
"abcd" == "ijkl" ? False
"abcd" == "ABCD" ? False
"abcd" == "abcd" ? True
*/
// Example for the String Equality operator.
printfn "This example of the String Equality 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 Equality operator
generates the following output.
"abcd" == "ijkl" ? False
"abcd" == "ABCD" ? False
"abcd" == "abcd" ? True
*)
설명
이 메서드는 Equality 클래스에 대한 같음 연산자의 연산을 정의합니다 String . 예제 섹션에 표시된 코드와 같은 코드를 사용하도록 설정합니다. 연산자는 서수(대/소문자를 구분하고 문화권을 구분하지 않는) 비교를 수행하는 정적 Equals(String, String) 메서드를 호출합니다.
메모
Visual Basic 컴파일러는 같음 연산자를 Equality 메서드에 대한 호출로 해결하지 않습니다. 대신 같음 연산자는 메서드에 대한 호출을 Operators.CompareString 래핑합니다.