Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
708 lines (624 sloc) 40.3 KB
<Type Name="Tuple&lt;T1&gt;" FullName="System.Tuple&lt;T1&gt;">
<TypeSignature Language="C#" Value="public class Tuple&lt;T1&gt; : IComparable, System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi serializable beforefieldinit Tuple`1&lt;T1&gt; extends System.Object implements class System.Collections.IStructuralComparable, class System.Collections.IStructuralEquatable, class System.IComparable" />
<TypeSignature Language="DocId" Value="T:System.Tuple`1" />
<TypeSignature Language="VB.NET" Value="Public Class Tuple(Of T1)&#xA;Implements IComparable, IStructuralComparable, IStructuralEquatable" />
<TypeSignature Language="C++ CLI" Value="generic &lt;typename T1&gt;&#xA;public ref class Tuple : IComparable, System::Collections::IStructuralComparable, System::Collections::IStructuralEquatable" />
<TypeSignature Language="F#" Value="type Tuple&lt;'T1&gt; = class&#xA; interface IStructuralEquatable&#xA; interface IStructuralComparable&#xA; interface IComparable" />
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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>
<TypeParameters>
<TypeParameter Name="T1" />
</TypeParameters>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.Collections.IStructuralComparable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.IStructuralEquatable</InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.IComparable</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="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.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0">
<AttributeName>System.Serializable</AttributeName>
</Attribute>
</Attributes>
<Docs>
<typeparam name="T1">The type of the tuple's only component.</typeparam>
<summary>Represents a 1-tuple, or singleton.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A tuple is a data structure that has a specific number and sequence of values. The <xref:System.Tuple%601> class represents a 1-tuple, or singleton, which is a tuple that has a single component. A singleton is used comparatively rarely in application development.
You can instantiate a <xref:System.Tuple%601> object by calling either the <xref:System.Tuple%601.%23ctor%2A> constructor or the static <xref:System.Tuple.Create%2A?displayProperty=nameWithType> method. You can retrieve the value of the tuple's single component by using the read-only <xref:System.Tuple%601.Item1%2A> instance property.
]]></format>
</remarks>
<altmember cref="T:System.Tuple" />
<altmember cref="T:System.Tuple`2" />
<altmember cref="T:System.Tuple`3" />
<altmember cref="T:System.Tuple`4" />
<altmember cref="T:System.Tuple`5" />
<altmember cref="T:System.Tuple`6" />
<altmember cref="T:System.Tuple`7" />
<altmember cref="T:System.Tuple`8" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public Tuple (T1 item1);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(!T1 item1) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.#ctor(`0)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (item1 As T1)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; Tuple(T1 item1);" />
<MemberSignature Language="F#" Value="new Tuple&lt;'T1&gt; : 'T1 -&gt; Tuple&lt;'T1&gt;" Usage="new System.Tuple&lt;'T1&gt; item1" />
<MemberType>Constructor</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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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>
<Parameters>
<Parameter Name="item1" Type="T1" />
</Parameters>
<Docs>
<param name="item1">The value of the tuple's only component.</param>
<summary>Initializes a new instance of the <see cref="T:System.Tuple`1" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can also use the static <xref:System.Tuple.Create%2A?displayProperty=nameWithType> method to instantiate a 1-tuple object without having to explicitly specify the type of its component. The following example uses the <xref:System.Tuple.Create%2A> method to instantiate a 1-tuple whose component is of type <xref:System.Int32>.
[!code-csharp[System.Tuple.Create#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple.create/cs/create1.cs#1)]
[!code-vb[System.Tuple.Create#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb#1)]
This is equivalent to the following call to the <xref:System.Tuple%601.%23ctor%2A> class constructor.
[!code-csharp[System.Tuple.Create#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple.create/cs/create1.cs#2)]
[!code-vb[System.Tuple.Create#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple.create/vb/create1.vb#2)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public override bool Equals (object obj);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool Equals(object obj) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.Equals(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function Equals (obj As Object) As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override bool Equals(System::Object ^ obj);" />
<MemberSignature Language="F#" Value="override this.Equals : obj -&gt; bool" Usage="tuple.Equals obj" />
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Object" />
</Parameters>
<Docs>
<param name="obj">The object to compare with this instance.</param>
<summary>Returns a value that indicates whether the current <see cref="T:System.Tuple`1" /> object is equal to a specified object.</summary>
<returns>
<see langword="true" /> if the current instance is equal to the specified object; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The `obj` parameter is considered to be equal to the current instance under the following conditions:
- It is a <xref:System.Tuple%601> object.
- Its single component is of the same type as the current instance.
- Its single component is equal to that of the current instance. Equality is determined by the default object equality comparer for each component.
## Examples
The following example calls the <xref:System.Tuple%601.Equals%28System.Object%29?displayProperty=nameWithType> method to compare a <xref:System.Tuple%601> object whose component is a <xref:System.Double> value with three <xref:System.Tuple%601> objects whose components have the following characteristics:
- Same type (<xref:System.Double>) and same value.
- Same type (<xref:System.Double>), but different value.
- Different type (<xref:System.Single>), but same value.
[!code-csharp[System.Tuple\`1.Equals#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple`1.equals/cs/equals1.cs#1)]
[!code-vb[System.Tuple\`1.Equals#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`1.equals/vb/equals1.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="GetHashCode">
<MemberSignature Language="C#" Value="public override int GetHashCode ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetHashCode() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.GetHashCode" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetHashCode () As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override int GetHashCode();" />
<MemberSignature Language="F#" Value="override this.GetHashCode : unit -&gt; int" Usage="tuple.GetHashCode " />
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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 />
<Docs>
<summary>Returns the hash code for the current <see cref="T:System.Tuple`1" /> object.</summary>
<returns>A 32-bit signed integer hash code.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Item1">
<MemberSignature Language="C#" Value="public T1 Item1 { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance !T1 Item1" />
<MemberSignature Language="DocId" Value="P:System.Tuple`1.Item1" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Item1 As T1" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property T1 Item1 { T1 get(); };" />
<MemberSignature Language="F#" Value="member this.Item1 : 'T1" Usage="System.Tuple&lt;'T1&gt;.Item1" />
<MemberType>Property</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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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>T1</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the value of the <see cref="T:System.Tuple`1" /> object's single component.</summary>
<value>The value of the current <see cref="T:System.Tuple`1" /> object's single component.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can determine the type of the <xref:System.Tuple%601.Item1%2A> component in one of two ways:
- By calling the `GetType` method on the value that is returned by the <xref:System.Tuple%601.Item1%2A> property.
- By retrieving the <xref:System.Type> object that represents the <xref:System.Tuple%601> object, and retrieving the first element from the array that is returned by its <xref:System.Type.GetGenericArguments%2A?displayProperty=nameWithType> method.
The example illustrates both approaches.
## Examples
The following example displays information about two singletons and their components.
[!code-csharp[System.Tuple\`1.Item1#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple`1.item1/cs/item1.cs#1)]
[!code-vb[System.Tuple\`1.Item1#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`1.item1/vb/item1.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="System.Collections.IStructuralComparable.CompareTo">
<MemberSignature Language="C#" Value="int IStructuralComparable.CompareTo (object other, System.Collections.IComparer comparer);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance int32 System.Collections.IStructuralComparable.CompareTo(object other, class System.Collections.IComparer comparer) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.System#Collections#IStructuralComparable#CompareTo(System.Object,System.Collections.IComparer)" />
<MemberSignature Language="VB.NET" Value="Function CompareTo (other As Object, comparer As IComparer) As Integer Implements IStructuralComparable.CompareTo" />
<MemberSignature Language="C++ CLI" Value=" virtual int System.Collections.IStructuralComparable.CompareTo(System::Object ^ other, System::Collections::IComparer ^ comparer) = System::Collections::IStructuralComparable::CompareTo;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.IStructuralComparable.CompareTo(System.Object,System.Collections.IComparer)</InterfaceMember>
</Implements>
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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="other" Type="System.Object" />
<Parameter Name="comparer" Type="System.Collections.IComparer" />
</Parameters>
<Docs>
<param name="other">An object to compare with the current instance.</param>
<param name="comparer">An object that provides custom rules for comparison.</param>
<summary>Compares the current <see cref="T:System.Tuple`1" /> object to a specified object by using a specified comparer, and returns an integer that indicates whether the current object is before, after, or in the same position as the specified object in the sort order.</summary>
<returns>A signed integer that indicates the relative position of this instance and <paramref name="other" /> in the sort order, as shown in the following table.
<list type="table"><listheader><term> Value
</term><description> Description
</description></listheader><item><term> A negative integer
</term><description> This instance precedes <paramref name="other" />.
</description></item><item><term> Zero
</term><description> This instance and <paramref name="other" /> have the same position in the sort order.
</description></item><item><term> A positive integer
</term><description> This instance follows <paramref name="other" />.
</description></item></list></returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Although this method can be called directly, it is most commonly called by collection sorting methods that include <xref:System.Collections.IComparer> parameters to order the members of a collection. For example, it is called by the <xref:System.Array.Sort%28System.Array%2CSystem.Collections.IComparer%29?displayProperty=nameWithType> method and the <xref:System.Collections.SortedList.Add%2A> method of a <xref:System.Collections.SortedList> object that is instantiated by using the <xref:System.Collections.SortedList.%23ctor%28System.Collections.IComparer%29?displayProperty=nameWithType> constructor.
> [!CAUTION]
> The <xref:System.Tuple%601.System%23Collections%23IStructuralComparable%23CompareTo%2A> method is intended for use in sorting operations. It should not be used when the primary purpose of a comparison is to determine whether two objects are equal. To determine whether two objects are equal, call the <xref:System.Tuple%601.System%23Collections%23IStructuralEquatable%23Equals%2A> method.
## Examples
The following example defines a generic class named `DescendingComparer` that implements the <xref:System.Collections.Generic.IComparer%601> interface. `DescendingComparer` sorts objects in descending rather than ascending order by reversing the value returned by the default comparer for a particular type. An instance of the generic `DescendingComparer` class is then passed to the <xref:System.Array.Sort%28System.Array%2CSystem.Collections.IComparer%29?displayProperty=nameWithType> method to sort an array of <xref:System.Tuple%601> objects in descending order. Note that the example does not directly call the <xref:System.Tuple%601.System%23Collections%23IStructuralComparable%23CompareTo%2A> method. This method is called implicitly by the <xref:System.Array.Sort%28System.Array%2CSystem.Collections.IComparer%29?displayProperty=nameWithType> method for each element in the array.
[!code-csharp[System.Tuple\`1.CompareTo#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple`1.compareto/cs/compareto2.cs#2)]
[!code-vb[System.Tuple\`1.CompareTo#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`1.compareto/vb/compareto2.vb#2)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="other" /> is not a <see cref="T:System.Tuple`1" /> object.</exception>
<altmember cref="M:System.Tuple`1.System#Collections#IStructuralEquatable#Equals(System.Object,System.Collections.IEqualityComparer)" />
</Docs>
</Member>
<Member MemberName="System.Collections.IStructuralEquatable.Equals">
<MemberSignature Language="C#" Value="bool IStructuralEquatable.Equals (object other, System.Collections.IEqualityComparer comparer);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance bool System.Collections.IStructuralEquatable.Equals(object other, class System.Collections.IEqualityComparer comparer) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.System#Collections#IStructuralEquatable#Equals(System.Object,System.Collections.IEqualityComparer)" />
<MemberSignature Language="VB.NET" Value="Function Equals (other As Object, comparer As IEqualityComparer) As Boolean Implements IStructuralEquatable.Equals" />
<MemberSignature Language="C++ CLI" Value=" virtual bool System.Collections.IStructuralEquatable.Equals(System::Object ^ other, System::Collections::IEqualityComparer ^ comparer) = System::Collections::IStructuralEquatable::Equals;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.IStructuralEquatable.Equals(System.Object,System.Collections.IEqualityComparer)</InterfaceMember>
</Implements>
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="other" Type="System.Object" />
<Parameter Name="comparer" Type="System.Collections.IEqualityComparer" />
</Parameters>
<Docs>
<param name="other">The object to compare with this instance.</param>
<param name="comparer">An object that defines the method to use to evaluate whether the two objects are equal.</param>
<summary>Returns a value that indicates whether the current <see cref="T:System.Tuple`1" /> object is equal to a specified object based on a specified comparison method.</summary>
<returns>
<see langword="true" /> if the current instance is equal to the specified object; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This member is an explicit interface member implementation. It can be used only when the <xref:System.Tuple%601> instance is cast to an <xref:System.Collections.IStructuralEquatable> interface.
The <xref:System.Collections.IEqualityComparer.Equals%2A?displayProperty=nameWithType> implementation is called only if `other` is not `null`, and if it can be successfully cast (in C#) or converted (in Visual Basic) to a <xref:System.Tuple%601> object whose single component is of the same type as the current instance. The method is passed the <xref:System.Tuple%601.Item1%2A> component of the current instance and the <xref:System.Tuple%601.Item1%2A> component of the <xref:System.Tuple%601> object represented by the `other` parameter.
## Examples
The following example defines an <xref:System.Collections.IEqualityComparer> implementation that considers two floating-point values to be equal if they are approximately equal to each other (that is, if one value is within .01 percent of the other).
[!code-csharp[System.Tuple\`1.Equals#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple`1.equals/cs/equals2.cs#2)]
[!code-vb[System.Tuple\`1.Equals#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`1.equals/vb/equals2.vb#2)]
]]></format>
</remarks>
<altmember cref="T:System.Collections.IEqualityComparer" />
</Docs>
</Member>
<Member MemberName="System.Collections.IStructuralEquatable.GetHashCode">
<MemberSignature Language="C#" Value="int IStructuralEquatable.GetHashCode (System.Collections.IEqualityComparer comparer);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance int32 System.Collections.IStructuralEquatable.GetHashCode(class System.Collections.IEqualityComparer comparer) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.System#Collections#IStructuralEquatable#GetHashCode(System.Collections.IEqualityComparer)" />
<MemberSignature Language="VB.NET" Value="Function GetHashCode (comparer As IEqualityComparer) As Integer Implements IStructuralEquatable.GetHashCode" />
<MemberSignature Language="C++ CLI" Value=" virtual int System.Collections.IStructuralEquatable.GetHashCode(System::Collections::IEqualityComparer ^ comparer) = System::Collections::IStructuralEquatable::GetHashCode;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer)</InterfaceMember>
</Implements>
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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="comparer" Type="System.Collections.IEqualityComparer" />
</Parameters>
<Docs>
<param name="comparer">An object whose <see cref="M:System.Collections.IEqualityComparer.GetHashCode(System.Object)" /> method calculates the hash code of the current <see cref="T:System.Tuple`1" /> object.</param>
<summary>Calculates the hash code for the current <see cref="T:System.Tuple`1" /> object by using a specified computation method.</summary>
<returns>A 32-bit signed integer hash code.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This member is an explicit interface member implementation. It can be used only when the <xref:System.Tuple%601> instance is cast to an <xref:System.Collections.IStructuralEquatable> interface.
The method simply wraps a call to the `comparer` object's <xref:System.Collections.IEqualityComparer.GetHashCode%2A?displayProperty=nameWithType> implementation.
The algorithm used to compute the hash code should return the same hash code for two <xref:System.Tuple%601> objects that are considered to be equal.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="System.IComparable.CompareTo">
<MemberSignature Language="C#" Value="int IComparable.CompareTo (object obj);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance int32 System.IComparable.CompareTo(object obj) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.System#IComparable#CompareTo(System.Object)" />
<MemberSignature Language="VB.NET" Value="Function CompareTo (obj As Object) As Integer Implements IComparable.CompareTo" />
<MemberSignature Language="C++ CLI" Value=" virtual int System.IComparable.CompareTo(System::Object ^ obj) = IComparable::CompareTo;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.IComparable.CompareTo(System.Object)</InterfaceMember>
</Implements>
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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="obj" Type="System.Object" />
</Parameters>
<Docs>
<param name="obj">An object to compare with the current instance.</param>
<summary>Compares the current <see cref="T:System.Tuple`1" /> object to a specified object, and returns an integer that indicates whether the current object is before, after, or in the same position as the specified object in the sort order.</summary>
<returns>A signed integer that indicates the relative position of this instance and <paramref name="obj" /> in the sort order, as shown in the following table.
<list type="table"><listheader><term> Value
</term><description> Description
</description></listheader><item><term> A negative integer
</term><description> This instance precedes <paramref name="obj" />.
</description></item><item><term> Zero
</term><description> This instance and <paramref name="obj" /> have the same position in the sort order.
</description></item><item><term> A positive integer
</term><description> This instance follows <paramref name="obj" />.
</description></item></list></returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This member is an explicit interface member implementation. It can be used only when the <xref:System.Tuple%601> instance is cast to an <xref:System.IComparable> interface.
This method provides the <xref:System.IComparable.CompareTo%2A?displayProperty=nameWithType> implementation for the <xref:System.Tuple%601> class. Although the method can be called directly, it is most commonly called by the default overloads of collection sorting methods, such as <xref:System.Array.Sort%28System.Array%29?displayProperty=nameWithType> and <xref:System.Collections.SortedList.Add%2A?displayProperty=nameWithType>, to order the members of a collection.
> [!CAUTION]
> The <xref:System.Tuple%601.System%23IComparable%23CompareTo%2A?displayProperty=nameWithType> method is intended for use in sorting operations. It should not be used when the primary purpose of a comparison is to determine whether two objects are equal. To determine whether two objects are equal, call the <xref:System.Tuple%601.Equals%2A> method.
The <xref:System.Tuple%601.System%23IComparable%23CompareTo%2A?displayProperty=nameWithType> method uses the default object comparer.
## Examples
The following example creates an array of singletons whose component is a <xref:System.Double> value. It displays the value of each tuple component in unsorted order, sorts the array, and then displays the values in sorted order. Note that the example does not directly call the <xref:System.Tuple%601.System%23IComparable%23CompareTo%2A?displayProperty=nameWithType> method. This method is called implicitly by the <xref:System.Array.Sort%28System.Array%29> method for each element in the array.
[!code-csharp[System.Tuple\`1.CompareTo#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple`1.compareto/cs/compareto1.cs#1)]
[!code-vb[System.Tuple\`1.CompareTo#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`1.compareto/vb/compareto1.vb#1)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="obj" /> is not a <see cref="T:System.Tuple`1" /> object.</exception>
<altmember cref="M:System.Tuple`1.Equals(System.Object)" />
</Docs>
</Member>
<Member MemberName="System.Runtime.CompilerServices.ITuple.Item">
<MemberSignature Language="C#" Value="object System.Runtime.CompilerServices.ITuple.Item[int index] { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance object System.Runtime.CompilerServices.ITuple.Item(int32)" />
<MemberSignature Language="DocId" Value="P:System.Tuple`1.System#Runtime#CompilerServices#ITuple#Item(System.Int32)" />
<MemberSignature Language="VB.NET" Value=" ReadOnly Property Item(index As Integer) As Object Implements ITuple.Item" />
<MemberSignature Language="C++ CLI" Value="property System::Object ^ System::Runtime::CompilerServices::ITuple::Item[int] { System::Object ^ get(int index); };" />
<MemberSignature Language="F#" Usage="System.Runtime.CompilerServices.ITuple.Item" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Runtime.CompilerServices.ITuple.Item(System.Int32)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="index" Type="System.Int32" Index="0" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netstandard-2.1" />
</Parameters>
<Docs>
<param name="index">The index of the <see langword="Tuple" /> element. <paramref name="index" /> must be 0.</param>
<summary>Gets the value of the <see langword="Tuple" /> element.</summary>
<value>The value of the <see langword="Tuple" /> element.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Tuple%601.System%23Runtime%23CompilerServices%23ITuple%23Item%2A?displayProperty=nameWithType> property is an explicit interface implementation. To call it, you must cast or convert the <xref:System.Tuple%601> object to an <xref:System.Runtime.CompilerServices.ITuple> interface object.
]]></format>
</remarks>
<exception cref="T:System.IndexOutOfRangeException">
<paramref name="index" /> is less than 0 or greater than 0.</exception>
</Docs>
</Member>
<Member MemberName="System.Runtime.CompilerServices.ITuple.Length">
<MemberSignature Language="C#" Value="int System.Runtime.CompilerServices.ITuple.Length { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 System.Runtime.CompilerServices.ITuple.Length" />
<MemberSignature Language="DocId" Value="P:System.Tuple`1.System#Runtime#CompilerServices#ITuple#Length" />
<MemberSignature Language="VB.NET" Value=" ReadOnly Property Length As Integer Implements ITuple.Length" />
<MemberSignature Language="C++ CLI" Value="property int System::Runtime::CompilerServices::ITuple::Length { int get(); };" />
<MemberSignature Language="F#" Usage="System.Runtime.CompilerServices.ITuple.Length" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Runtime.CompilerServices.ITuple.Length</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Runtime</AssemblyName>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
<AssemblyVersion>4.2.1.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the number of elements in the <see langword="Tuple" />.</summary>
<value>1, the number of elements in a <see cref="T:System.Tuple`1" /> object.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Tuple%601.System%23Runtime%23CompilerServices%23ITuple%23Length%2A> property is an explicit interface implementation. To call it, you must cast or convert the <xref:System.Tuple%601> object to an <xref:System.Runtime.CompilerServices.ITuple> interface object.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="ToString">
<MemberSignature Language="C#" Value="public override string ToString ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance string ToString() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Tuple`1.ToString" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function ToString () As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override System::String ^ ToString();" />
<MemberSignature Language="F#" Value="override this.ToString : unit -&gt; string" Usage="tuple.ToString " />
<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>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>mscorlib</AssemblyName>
<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.String</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns a string that represents the value of this <see cref="T:System.Tuple`1" /> instance.</summary>
<returns>The string representation of this <see cref="T:System.Tuple`1" /> object.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The string returned by this method takes the form (*Item1*), where *Item1* represents the value of the <xref:System.Tuple%601.Item1%2A> property. If the value of <xref:System.Tuple%601.Item1%2A> is `null`, it is represented as <xref:System.String.Empty?displayProperty=nameWithType>.
## Examples
The following example illustrates the <xref:System.Tuple%601.ToString%2A> method.
[!code-csharp[System.Tuple\`1.ToString#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.tuple`1.tostring/cs/tostring1.cs#1)]
[!code-vb[System.Tuple\`1.ToString#1](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.tuple`1.tostring/vb/tostring1.vb#1)]
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.