Export (0) Print
Expand All

Tuple<T1>.Item1 Property

Gets the value of the Tuple<T1> object's single component.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public T1 Item1 { get; }

Property Value

Type: T1
The value of the current Tuple<T1> object's single component.

You can determine the type of the Item1 component in one of two ways:

  • By calling the GetType method on the value that is returned by the Item1 property.

  • By retrieving the Type object that represents the Tuple<T1> object, and retrieving the first element from the array that is returned by its Type.GetGenericArguments method.

The example illustrates both approaches.

The following example displays information about two singletons and their components.

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      var tuple1 = Tuple.Create(-1.23445e-32);
      // Display information about this singleton.
      Type tuple1Type = tuple1.GetType();
      Console.WriteLine("First 1-Tuple:");
      Console.WriteLine("   Type: {0}", tuple1Type.Name);
      Console.WriteLine("   Generic Parameter Type: {0}", 
                        tuple1Type.GetGenericArguments()[0]);
      Console.WriteLine("   Component Value: {0}", tuple1.Item1);
      Console.WriteLine("   Component Value Type: {0}", 
                        tuple1.Item1.GetType().Name);
      Console.WriteLine();

      var tuple2 = Tuple.Create((BigInteger)1.83789322281780983781356676e103);
      // Display information about this singleton.
      Type tuple2Type = tuple2.GetType();
      Console.WriteLine("Second 1-Tuple:");
      Console.WriteLine("   Type: {0}", tuple2Type.Name);
      Console.WriteLine("   Generic Parameter Type: {0}", 
                        tuple2Type.GetGenericArguments()[0]);
      Console.WriteLine("   Component Value: {0}", tuple2.Item1);
      Console.WriteLine("   Component Value Type: {0}", 
                        tuple2.Item1.GetType().Name);
   }
}
// The example displays the following output: 
//       First 1-Tuple: 
//          Type: Tuple`1 
//          Generic Parameter Type: System.Double 
//          Component Value: -1.23445E-32 
//          Component Value Type: Double 
//        
//       Second 1-Tuple: 
//          Type: Tuple`1 
//          Generic Parameter Type: System.Numerics.BigInteger 
//          Component Value: 1.8378932228178098168858909492E+103 
//          Component Value Type: BigInteger

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft