SortKey.Equals(Object) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정한 개체와 현재 SortKey 개체가 같은지 여부를 확인합니다.
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
매개 변수가 현재 SortKey 개체와 같으면 true
이고, 그렇지 않으면 false
입니다.
예외
value
이(가) null
인 경우
예제
다음 코드 예제에서는 다른 SortKey 개체와 비교 하는 경우의 Equals 결과 보여 입니다.
using namespace System;
using namespace System::Globalization;
int main()
{
// Creates two identical en-US cultures and one de-DE culture.
CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
CompareInfo^ myComp_enUS1 = MyCI->CompareInfo;
MyCI = gcnew CultureInfo( "en-US",false );
CompareInfo^ myComp_enUS2 = MyCI->CompareInfo;
MyCI = gcnew CultureInfo( "de-DE",false );
CompareInfo^ myComp_deDE = MyCI->CompareInfo;
// Creates the base SortKey to compare with all the others.
SortKey^ mySK1 = myComp_enUS1->GetSortKey( "cant", CompareOptions::StringSort );
// Creates a SortKey that is derived exactly the same way as the base SortKey.
SortKey^ mySK2 = myComp_enUS1->GetSortKey( "cant", CompareOptions::StringSort );
// Creates a SortKey that uses word sort, which is the default sort.
SortKey^ mySK3 = myComp_enUS1->GetSortKey( "cant" );
// Creates a SortKey for a different String*.
SortKey^ mySK4 = myComp_enUS1->GetSortKey( "can't", CompareOptions::StringSort );
// Creates a SortKey from a different CompareInfo with the same culture.
SortKey^ mySK5 = myComp_enUS2->GetSortKey( "cant", CompareOptions::StringSort );
// Creates a SortKey from a different CompareInfo with a different culture.
SortKey^ mySK6 = myComp_deDE->GetSortKey( "cant", CompareOptions::StringSort );
// Compares the base SortKey with itself.
Console::WriteLine( "Comparing the base SortKey with itself: {0}", mySK1->Equals( mySK1 ) );
Console::WriteLine();
// Prints the header for the table.
Console::WriteLine( "CompareInfo Culture OriginalString CompareOptions Equals()" );
// Compares the base SortKey with a SortKey that is
// created from the same CompareInfo with the same String* and the same CompareOptions.
Console::WriteLine( "same same same same {0}", mySK1->Equals( mySK2 ) );
// Compares the base SortKey with a SortKey that is
// created from the same CompareInfo with the same String* but with different CompareOptions.
Console::WriteLine( "same same same different {0}", mySK1->Equals( mySK3 ) );
// Compares the base SortKey with a SortKey that is
// created from the same CompareInfo with the different String*
// but with the same CompareOptions.
Console::WriteLine( "same same different same {0}", mySK1->Equals( mySK4 ) );
// Compares the base SortKey with a SortKey that is
// created from a different CompareInfo (same culture)
// with the same String* and the same CompareOptions.
Console::WriteLine( "different same same same {0}", mySK1->Equals( mySK5 ) );
// Compares the base SortKey with a SortKey that is
// created from a different CompareInfo (different culture)
// with the same String* and the same CompareOptions.
Console::WriteLine( "different different same same {0}", mySK1->Equals( mySK6 ) );
}
/*
This code produces the following output.
Comparing the base SortKey with itself: True
CompareInfo Culture OriginalString CompareOptions Equals()
same same same same True
same same same different False
same same different same False
different same same same True
different different same same False
*/
using System;
using System.Globalization;
public class SamplesSortKey {
public static void Main() {
// Creates two identical en-US cultures and one de-DE culture.
CompareInfo myComp_enUS1 = new CultureInfo("en-US",false).CompareInfo;
CompareInfo myComp_enUS2 = new CultureInfo("en-US",false).CompareInfo;
CompareInfo myComp_deDE = new CultureInfo("de-DE",false).CompareInfo;
// Creates the base SortKey to compare with all the others.
SortKey mySK1 = myComp_enUS1.GetSortKey( "cant", CompareOptions.StringSort );
// Creates a SortKey that is derived exactly the same way as the base SortKey.
SortKey mySK2 = myComp_enUS1.GetSortKey( "cant", CompareOptions.StringSort );
// Creates a SortKey that uses word sort, which is the default sort.
SortKey mySK3 = myComp_enUS1.GetSortKey( "cant" );
// Creates a SortKey for a different string.
SortKey mySK4 = myComp_enUS1.GetSortKey( "can't", CompareOptions.StringSort );
// Creates a SortKey from a different CompareInfo with the same culture.
SortKey mySK5 = myComp_enUS2.GetSortKey( "cant", CompareOptions.StringSort );
// Creates a SortKey from a different CompareInfo with a different culture.
SortKey mySK6 = myComp_deDE.GetSortKey( "cant", CompareOptions.StringSort );
// Compares the base SortKey with itself.
Console.WriteLine( "Comparing the base SortKey with itself: {0}", mySK1.Equals( mySK1 ) );
Console.WriteLine();
// Prints the header for the table.
Console.WriteLine( "CompareInfo Culture OriginalString CompareOptions Equals()" );
// Compares the base SortKey with a SortKey that is
// created from the same CompareInfo with the same string and the same CompareOptions.
Console.WriteLine( "same same same same {0}", mySK1.Equals( mySK2 ) );
// Compares the base SortKey with a SortKey that is
// created from the same CompareInfo with the same string but with different CompareOptions.
Console.WriteLine( "same same same different {0}", mySK1.Equals( mySK3 ) );
// Compares the base SortKey with a SortKey that is
// created from the same CompareInfo with the different string
// but with the same CompareOptions.
Console.WriteLine( "same same different same {0}", mySK1.Equals( mySK4 ) );
// Compares the base SortKey with a SortKey that is
// created from a different CompareInfo (same culture)
// with the same string and the same CompareOptions.
Console.WriteLine( "different same same same {0}", mySK1.Equals( mySK5 ) );
// Compares the base SortKey with a SortKey that is
// created from a different CompareInfo (different culture)
// with the same string and the same CompareOptions.
Console.WriteLine( "different different same same {0}", mySK1.Equals( mySK6 ) );
}
}
/*
This code produces the following output.
Comparing the base SortKey with itself: True
CompareInfo Culture OriginalString CompareOptions Equals()
same same same same True
same same same different False
same same different same False
different same same same True
different different same same False
*/
Imports System.Globalization
Public Class SamplesSortKey
Public Shared Sub Main()
' Creates two identical en-US cultures and one de-DE culture.
Dim myComp_enUS1 As CompareInfo = New CultureInfo("en-US", False).CompareInfo
Dim myComp_enUS2 As CompareInfo = New CultureInfo("en-US", False).CompareInfo
Dim myComp_deDE As CompareInfo = New CultureInfo("de-DE", False).CompareInfo
' Creates the base SortKey to compare with all the others.
Dim mySK1 As SortKey = myComp_enUS1.GetSortKey("cant", CompareOptions.StringSort)
' Creates a SortKey that is derived exactly the same way as the base SortKey.
Dim mySK2 As SortKey = myComp_enUS1.GetSortKey("cant", CompareOptions.StringSort)
' Creates a SortKey that uses word sort, which is the default sort.
Dim mySK3 As SortKey = myComp_enUS1.GetSortKey("cant")
' Creates a SortKey for a different string.
Dim mySK4 As SortKey = myComp_enUS1.GetSortKey("can't", CompareOptions.StringSort)
' Creates a SortKey from a different CompareInfo with the same culture.
Dim mySK5 As SortKey = myComp_enUS2.GetSortKey("cant", CompareOptions.StringSort)
' Creates a SortKey from a different CompareInfo with a different culture.
Dim mySK6 As SortKey = myComp_deDE.GetSortKey("cant", CompareOptions.StringSort)
' Compares the base SortKey with itself.
Console.WriteLine("Comparing the base SortKey with itself: {0}", mySK1.Equals(mySK1))
Console.WriteLine()
' Prints the header for the table.
Console.WriteLine("CompareInfo Culture OriginalString CompareOptions Equals()")
' Compares the base SortKey with a SortKey that is
' created from the same CompareInfo with the same string and the same CompareOptions.
Console.WriteLine("same same same same {0}", mySK1.Equals(mySK2))
' Compares the base SortKey with a SortKey that is
' created from the same CompareInfo with the same string but with different CompareOptions.
Console.WriteLine("same same same different {0}", mySK1.Equals(mySK3))
' Compares the base SortKey with a SortKey that is
' created from the same CompareInfo with the different string
' but with the same CompareOptions.
Console.WriteLine("same same different same {0}", mySK1.Equals(mySK4))
' Compares the base SortKey with a SortKey that is
' created from a different CompareInfo (same culture)
' with the same string and the same CompareOptions.
Console.WriteLine("different same same same {0}", mySK1.Equals(mySK5))
' Compares the base SortKey with a SortKey that is
' created from a different CompareInfo (different culture)
' with the same string and the same CompareOptions.
Console.WriteLine("different different same same {0}", mySK1.Equals(mySK6))
End Sub
End Class
'This code produces the following output.
'
'Comparing the base SortKey with itself: True
'
'CompareInfo Culture OriginalString CompareOptions Equals()
'same same same same True
'same same same different False
'same same different same False
'different same same same True
'different different same same False
설명
속성이 같으면 KeyData 두 SortKey 개체가 같음으로 간주됩니다.
이 메서드는 Object.Equals를 재정의합니다.
적용 대상
추가 정보
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET