﻿<?xml version="1.0" encoding="utf-8"?><Type Name="IComparer&lt;T&gt;" FullName="System.Collections.Generic.IComparer&lt;T&gt;"><TypeSignature Language="C#" Value="public interface IComparer&lt;in T&gt;" /><TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IComparer`1&lt;- T&gt;" /><AssemblyInfo><AssemblyName>mscorlib</AssemblyName><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><TypeParameters><TypeParameter Name="T"><Constraints><ParameterAttribute>Contravariant</ParameterAttribute></Constraints></TypeParameter></TypeParameters><Interfaces /><Docs><typeparam name="T">To be added.</typeparam><since version=".NET 2.0" /><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para>This interface is used with the <see cref="Overload:System.Collections.Generic.List`1.Sort" /> and <see cref="Overload:System.Collections.Generic.List`1.BinarySearch" /> methods. It provides a way to customize the sort order of a collection. Classes that implement this interface include the <see cref="T:System.Collections.Generic.SortedDictionary`2" /> and <see cref="T:System.Collections.Generic.SortedList`2" /> generic classes.</para><para>The default implementation of this interface is the <see cref="T:System.Collections.Generic.Comparer`1" /> class. The <see cref="T:System.StringComparer" /> class implements this interface for type <see cref="T:System.String" />.</para><para>This interface supports ordering comparisons. That is, when the <see cref="M:System.Collections.Generic.Comparer`1.Compare(`0,`0)" /> method returns 0, it means that two objects sort the same. Implementation of exact equality comparisons is provided by the <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> generic interface. </para><para>We recommend that you derive from the <see cref="T:System.Collections.Generic.Comparer`1" /> class instead of implementing the <see cref="T:System.Collections.Generic.IComparer`1" /> interface, because the <see cref="T:System.Collections.Generic.Comparer`1" /> class provides an explicit interface implementation of the <see cref="M:System.Collections.Generic.Comparer`1.System#Collections#IComparer#Compare(System.Object,System.Object)" /> method and the <see cref="P:System.Collections.Generic.Comparer`1.Default" /> property that gets the default comparer for the object.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Defines a method that a type implements to compare two objects.</para></summary></Docs><Members><Member MemberName="Compare"><MemberSignature Language="C#" Value="public int Compare (T x, T y);" /><MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance int32 Compare(!T x, !T y) cil managed" /><MemberType>Method</MemberType><AssemblyInfo><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>System.Int32</ReturnType></ReturnValue><Parameters><Parameter Name="x" Type="T" /><Parameter Name="y" Type="T" /></Parameters><Docs><param name="x">First <see langword="T" /> to compare.</param><param name="y">Second <see langword="T" /> to compare.</param><summary><para> Returns the sort order of two <see langword="T" /> instances.</para></summary><returns><para>A <see cref="T:System.Int32" /> containing a value that reflects the sort order of
<paramref name="x" /> as compared to <paramref name="y" />. The following table defines the conditions
   under which the returned value is a negative number, zero, or a positive
   number.</para><list type="table"><listheader><term>Value</term><description>Condition</description></listheader><item><term> A negative number</term><description><paramref name="x" /> &lt; <paramref name="y" />.</description></item><item><term> Zero</term><description><paramref name="x" /> == <paramref name="y" />.</description></item><item><term> A positive number</term><description><paramref name="x" /> &gt; <paramref name="y" />.</description></item></list></returns><remarks><block subset="none" type="behaviors"><para>For any objects A, B and C, the following are required to be true:</para><para>Compare(A,A) is required to return zero. </para><para>If Compare(A,B) returns zero then Compare(B,A) is required to return zero.</para><para>If Compare(A,B) is zero, then Compare(B,C) and Compare(A,C) must have the same sign (negative, zero or positive).</para><para>If Compare(B,C) is zero, then Compare(A,B) and Compare(A,C) must have the same sign (negative, zero or positive).</para><para>If Compare(A,B) returns zero and Compare(B,C) returns zero then Compare(A,C) is required to return zero.</para><para>If Compare(A,B) returns a value other than zero then Compare(B,A) is required to return a value of the opposite sign.</para><para>If Compare(A,B) returns a value <paramref name="x" /> not equal 
      to zero, and Compare(B,C) returns a value <paramref name="y" /> of the same sign as
   <paramref name="x" />, then Compare(A,C) is required to a value of the same sign as 
   <paramref name="x" /> and <paramref name="y" /> 
   .</para><para>The exact behavior of this method is unspecified. The intent of this method is
   to provide a mechanism that orders instances of a class in a manner that is
   consistent with the mathematical definitions of the relational operators (&lt;,
   &gt;, and ==), without regard for class-specific definitions of the
   operators.</para></block></remarks><since version=".NET 2.0" /></Docs></Member></Members></Type>