Encoding.Equals(Object) 메서드

정의

지정한 Object가 현재 인스턴스와 같은지를 확인합니다.

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

매개 변수

value
Object

현재 인스턴스와 비교할 Object입니다.

반환

Boolean

truevalue의 인스턴스이고 현재 인스턴스와 같으면 Encoding이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 동일한 인코딩의 두 인스턴스 (코드 페이지에 의해 하나씩, 다른 이름으로 다른 인스턴스)를 가져오고 같은지 확인 합니다.

using namespace System;
using namespace System::Text;
int main()
{
   
   // Get a UTF-32 encoding by codepage.
   Encoding^ e1 = Encoding::GetEncoding( 12000 );
   
   // Get a UTF-32 encoding by name.
   Encoding^ e2 = Encoding::GetEncoding( "utf-32" );
   
   // Check their equality.
   Console::WriteLine( "e1 equals e2? {0}", e1->Equals( e2 ) );
}

/* 
This code produces the following output.

e1 equals e2? True

*/
using System;
using System.Text;

public class SamplesEncoding  {

   public static void Main()  {

      // Get a UTF-32 encoding by codepage.
      Encoding e1 = Encoding.GetEncoding( 12000 );

      // Get a UTF-32 encoding by name.
      Encoding e2 = Encoding.GetEncoding( "utf-32" );

      // Check their equality.
      Console.WriteLine( "e1 equals e2? {0}", e1.Equals( e2 ) );
   }
}


/* 
This code produces the following output.

e1 equals e2? True

*/
Imports System.Text

Public Class SamplesEncoding   

   Public Shared Sub Main()

      ' Get a UTF-32 encoding by codepage.
      Dim e1 As Encoding = Encoding.GetEncoding(12000)

      ' Get a UTF-32 encoding by name.
      Dim e2 As Encoding = Encoding.GetEncoding("utf-32")

      ' Check their equality.
      Console.WriteLine("e1 equals e2? {0}", e1.Equals(e2))

   End Sub

End Class


'This code produces the following output.
'
'e1 equals e2? True

설명

Encoding동일한 코드 페이지에 해당 하 고 및 개체가 같은 경우의 두 인스턴스는 동일한 것으로 간주 됩니다 EncoderFallback DecoderFallback . 특히 파생 된 코드 페이지에는 모두 0의 코드 페이지가 있으며 해당 대체는 정상적으로 null ( Nothing Visual Basic .net)입니다. 따라서 모두 서로 같다고 간주 됩니다. 한 가지 결과는 Equals 를 사용 하 여 해시 테이블을 채울 때 모든 파생 인코딩이 동일 하 고 동일한 해시 테이블 슬롯을 사용 한다는 것입니다.

적용 대상

추가 정보