String.Equality(String, String) 연산자
정의
지정된 두 문자열의 값이 같은지를 확인합니다.Determines whether two specified strings have the same value.
public:
static bool operator ==(System::String ^ a, System::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
입니다.The first string to compare, or null
.
- b
- String
비교할 두 번째 문자열 또는 null
입니다.The second string to compare, or null
.
반환
true
의 값이 a
의 값과 같으면 b
를 반환하고, 그러지 않으면 false
를 반환합니다.true
if the value of a
is the same as the value of b
; otherwise, false
.
예제
다음 예제에서는 같음 연산자를 보여 줍니다.The following example demonstrates the equality operator.
// Example for the String Equality 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 Equality operator\n"
"generates the following output.\n" );
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
*/
// 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
*/
설명
합니다 Equality 에 대 한 같음 연산자의 작업을 정의 하는 메서드를 String 클래스입니다.The Equality method defines the operation of the equality operator for the String class. 코드를 예제에서는 섹션에 나와 있는 것과 같은 수 있습니다.It enables code such as that shown in the Example section. 연산자를 호출 하는 정적 Equals(String, String) 메서드는 서 수 (대/소문자 구분 및 문화권을 구분 하지 않는) 비교를 수행 합니다.The operator, in turn, calls the static Equals(String, String) method, which performs an ordinal (case-sensitive and culture-insensitive) comparison.
참고
Visual Basic 컴파일러 같음 연산자에 대 한 호출으로 해결 되지 않으면를 Equality 메서드.The Visual Basic compiler does not resolve the equality operator as a call to the Equality method. 대신 같음 연산자에 대 한 호출을 래핑하는 Operators.CompareString 메서드.Instead, the equality operator wraps a call to the Operators.CompareString method.