Uri.Equals(Object) 메서드

정의

Uri 인스턴스가 같은지 비교합니다.

public:
 override bool Equals(System::Object ^ comparand);
public override bool Equals (object comparand);
public override bool Equals (object? comparand);
override this.Equals : obj -> bool
Public Overrides Function Equals (comparand As Object) As Boolean

매개 변수

comparand
Object

현재 인스턴스와 비교할 URI 또는 URI 식별자입니다.

반환

Boolean

두 인스턴스가 같은 URI를 나타내면 true이고, 그렇지 않으면 false입니다.

예제

이 예제에서는 문자열에서 두 인스턴스 Uri 를 만들고 비교하여 동일한 값을 나타내는지 여부를 확인합니다. address1이 비교를 위해 부분이 무시되기 때문에 Fragment address2는 동일합니다. 결과는 콘솔에 기록됩니다.

// Create some Uris.
Uri^ address1 = gcnew Uri( "http://www.contoso.com/index.htm#search" );
Uri^ address2 = gcnew Uri( "http://www.contoso.com/index.htm" );
if ( address1->Equals( address2 ) )
{
   Console::WriteLine( "The two addresses are equal" );
}
else
{
   Console::WriteLine( "The two addresses are not equal" );
}
// Will output "The two addresses are equal"
// Create some Uris.
Uri address1 = new Uri("http://www.contoso.com/index.htm#search");
Uri address2 = new Uri("http://www.contoso.com/index.htm");
if (address1.Equals(address2))
    Console.WriteLine("The two addresses are equal");
else
    Console.WriteLine("The two addresses are not equal");
// Will output "The two addresses are equal"
// Create some Uris.
let address1 = Uri "http://www.contoso.com/index.htm#search"
let address2 = Uri "http://www.contoso.com/index.htm"
if address1.Equals address2 then
    printfn "The two addresses are equal"
else
    printfn "The two addresses are not equal"
// Will output "The two addresses are equal"
' Create some Uris.
Dim address1 As New Uri("http://www.contoso.com/index.htm#search")
Dim address2 As New Uri("http://www.contoso.com/index.htm")
If address1.Equals(address2) Then
    Console.WriteLine("The two addresses are equal")
Else
    Console.WriteLine("The two addresses are not equal")
End If
' Will output "The two addresses are equal"

설명

이 메서드는 Equals 포함할 수 있는 사용자 정보() 및 조각Fragment(UserInfo) 부분과 관계없이 두 인스턴스를 비교합니다. 예를 들어 URI http://www.contoso.com/index.htm#searchhttp://user:password@www.contoso.com/index.htm메서드가 Equals 반환 true됩니다.

Uri 인스턴스가 유니코드 호스트 이름으로 구성되고 comparand 매개 변수에 해당하는 Punycode Equals 호스트 이름을 가진 호스트 이름으로 구성된 인스턴스 또는 식별자가 포함된 Uri 경우 IRI(International Resource Identifier) 및 IDN(Internationalized Domain Name) 지원이 활성화된 경우에만 반환 true 됩니다. Punycode 이름에는 ASCII 문자만 사용되며 항상 xn-- 접두사로 시작합니다.

IRI 지원에 대한 자세한 내용은 클래스의 설명 섹션을 Uri 참조하세요.

참고

.NET Framework 버전 1.0 및 1.1에서도 Query 무시됩니다.

참고

메서드는 Equals 파생 클래스에서 재정의할 수 있습니다. 악의적인 엔터티가 메서드를 수정할 수 있으므로 주의해야 합니다. 이 인스턴스가 신뢰할 수 있는 원본에서 온 것을 알지 못하면 이 메서드를 사용하여 보안 검사를 수행하면 안 됩니다.

적용 대상