-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathIComparer`1.xml
195 lines (170 loc) · 13.7 KB
/
IComparer`1.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<Type Name="IComparer<T>" FullName="System.Collections.Generic.IComparer<T>">
<TypeSignature Language="C#" Value="public interface IComparer<in T>" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.0;netstandard-1.1;netstandard-1.2;netstandard-1.3;netstandard-1.4;netstandard-1.5;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IComparer`1<- T>" FrameworkAlternate="dotnet-uwp-10.0;net-5.0;net-6.0;net-7.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.0;netstandard-1.1;netstandard-1.2;netstandard-1.3;netstandard-1.4;netstandard-1.5;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<TypeSignature Language="DocId" Value="T:System.Collections.Generic.IComparer`1" />
<TypeSignature Language="VB.NET" Value="Public Interface IComparer(Of In T)" FrameworkAlternate="dotnet-uwp-10.0;net-10.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.0;netstandard-1.1;netstandard-1.2;netstandard-1.3;netstandard-1.4;netstandard-1.5;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<TypeSignature Language="F#" Value="type IComparer<'T> = interface" />
<TypeSignature Language="C++ CLI" Value="generic <typename T>
public interface class IComparer" />
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract beforefieldinit IComparer`1<- T>" FrameworkAlternate="net-10.0;net-8.0;net-9.0" />
<TypeSignature Language="C#" Value="public interface IComparer<T>" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5" />
<TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IComparer`1<T>" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5" />
<TypeSignature Language="VB.NET" Value="Public Interface IComparer(Of T)" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5" />
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.20.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="mscorlib" FromVersion="4.0.0.0" To="System.Runtime" ToVersion="0.0.0.0" FrameworkAlternate="dotnet-uwp-10.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime" ToVersion="10.0.0.0" FrameworkAlternate="net-10.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Runtime" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
<TypeForwarding From="System.Runtime" FromVersion="4.1.1.1" To="mscorlib" ToVersion="4.0.0.0" FrameworkAlternate="netframework-4.6.2-pp" />
</TypeForwardingChain>
<TypeParameters>
<TypeParameter Name="T">
<Constraints>
<ParameterAttribute>Contravariant</ParameterAttribute>
</Constraints>
</TypeParameter>
</TypeParameters>
<Interfaces />
<Docs>
<typeparam name="T">The type of objects to compare.</typeparam>
<summary>Defines a method that a type implements to compare two objects.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This interface is used with the <xref:System.Collections.Generic.List%601.Sort%2A?displayProperty=nameWithType> and <xref:System.Collections.Generic.List%601.BinarySearch%2A?displayProperty=nameWithType> methods. It provides a way to customize the sort order of a collection. Classes that implement this interface include the <xref:System.Collections.Generic.SortedDictionary%602> and <xref:System.Collections.Generic.SortedList%602> generic classes.
The default implementation of this interface is the <xref:System.Collections.Generic.Comparer%601> class. The <xref:System.StringComparer> class implements this interface for type <xref:System.String>.
This interface supports ordering comparisons. That is, when the <xref:System.Collections.Generic.Comparer%601.Compare%2A> method returns 0, it means that two objects sort the same. Implementation of exact equality comparisons is provided by the <xref:System.Collections.Generic.IEqualityComparer%601> generic interface.
We recommend that you derive from the <xref:System.Collections.Generic.Comparer%601> class instead of implementing the <xref:System.Collections.Generic.IComparer%601> interface, because the <xref:System.Collections.Generic.Comparer%601> class provides an explicit interface implementation of the <xref:System.Collections.Generic.Comparer%601.System%23Collections%23IComparer%23Compare%2A> method and the <xref:System.Collections.Generic.Comparer%601.Default%2A> property that gets the default comparer for the object.
## Examples
The following example implements the <xref:System.Collections.Generic.IComparer%601> interface to compare objects of type `Box` according to their dimensions. This example is part of a larger example provided for the <xref:System.Collections.Generic.Comparer%601> class.
:::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ComparerT/Overview/program.cs" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.generic.boxcompare/vb/program.vb" id="Snippet7":::
]]></format>
</remarks>
<altmember cref="T:System.Collections.Generic.Comparer`1" />
<altmember cref="N:System.Collections" />
<altmember cref="P:System.Threading.Thread.CurrentCulture" />
<altmember cref="T:System.Globalization.CompareInfo" />
<altmember cref="T:System.Globalization.CultureInfo" />
<altmember cref="T:System.Collections.Generic.IEqualityComparer`1" />
</Docs>
<Members>
<Member MemberName="Compare">
<MemberSignature Language="C#" Value="public int Compare (T x, T y);" FrameworkAlternate="dotnet-uwp-10.0;netcore-1.0;netcore-1.1;netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.6.2-pp;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-1.0;netstandard-1.1;netstandard-1.2;netstandard-1.3;netstandard-1.4;netstandard-1.5;netstandard-1.6;netstandard-2.0;netstandard-2.1" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance int32 Compare(!T x, !T y) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Collections.Generic.IComparer`1.Compare(`0,`0)" />
<MemberSignature Language="VB.NET" Value="Public Function Compare (x As T, y As T) As Integer" />
<MemberSignature Language="F#" Value="abstract member Compare : 'T * 'T -> int" Usage="iComparer.Compare (x, y)" />
<MemberSignature Language="C#" Value="public int Compare (T? x, T? y);" FrameworkAlternate="net-10.0;net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="C++ CLI" Value="public:
 int Compare(T x, T y);" FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.0.20.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
<AssemblyVersion>4.2.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="x" Type="T">
<Attributes>
<Attribute FrameworkAlternate="netcore-3.0;netcore-3.1;netframework-4.6.2-pp">
<AttributeName Language="C#">[System.Diagnostics.CodeAnalysis.AllowNull]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.CodeAnalysis.AllowNull>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
<Parameter Name="y" Type="T">
<Attributes>
<Attribute FrameworkAlternate="netcore-3.0;netcore-3.1;netframework-4.6.2-pp">
<AttributeName Language="C#">[System.Diagnostics.CodeAnalysis.AllowNull]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.CodeAnalysis.AllowNull>]</AttributeName>
</Attribute>
</Attributes>
</Parameter>
</Parameters>
<Docs>
<param name="x">The first object to compare.</param>
<param name="y">The second object to compare.</param>
<summary>Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.</summary>
<returns>A signed integer that indicates the relative values of <paramref name="x" /> and <paramref name="y" />, as shown in the following table.
<list type="table"><listheader><term> Value
</term><description> Meaning
</description></listheader><item><term> Less than zero
</term><description><paramref name="x" /> is less than <paramref name="y" />.
</description></item><item><term> Zero
</term><description><paramref name="x" /> equals <paramref name="y" />.
</description></item><item><term> Greater than zero
</term><description><paramref name="x" /> is greater than <paramref name="y" />.
</description></item></list></returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Implement this method to provide a customized sort order comparison for type `T`.
Comparing `null` with any reference type is allowed and does not generate an exception. A null reference is considered to be less than any reference that is not null.
## Examples
The following example implements the <xref:System.Collections.Generic.IComparer%601> interface to compare objects of type `Box` according to their dimensions. This example is part of a larger example provided for the <xref:System.Collections.Generic.Comparer%601> class.
:::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ComparerT/Overview/program.cs" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.generic.boxcompare/vb/program.vb" id="Snippet7":::
]]></format>
</remarks>
<altmember cref="T:System.IComparable`1" />
<altmember cref="P:System.Threading.Thread.CurrentCulture" />
<altmember cref="T:System.Globalization.CompareInfo" />
<altmember cref="T:System.Globalization.CultureInfo" />
</Docs>
</Member>
</Members>
</Type>