# Tuple<T1,T2>.Item1 Eigenschaft

## Definition

Ruft den Wert der ersten Komponente des aktuellen Tuple<T1,T2>-Objekts ab.Gets the value of the current Tuple<T1,T2> object's first component.

``````public:
property T1 Item1 { T1 get(); };``````
``public T1 Item1 { get; }``
``member this.Item1 : 'T1``
``Public ReadOnly Property Item1 As T1``

#### Eigenschaftswert

T1

Der Wert der ersten Komponente des aktuellen Tuple<T1,T2>-Objekts.The value of the current Tuple<T1,T2> object's first component.

## Beispiele

Das Beispiel veranschaulicht die Verwendung der Item1 -Eigenschaft und der-Eigenschaft Item2 zum Definieren einer Methode, die mehrere Werte in Form eines 2-Tupels zurückgibt.The example illustrates the use of the Item1 and Item2 properties to define a method that returns multiple values in the form of a 2-tuple.

``````using System;

public class Class1
{
public static void Main()
{
int dividend, divisor;
Tuple<int, int> result;

dividend = 136945; divisor = 178;
result = IntegerDivide(dividend, divisor);
if (result != null)
Console.WriteLine(@"{0} \ {1} = {2}, remainder {3}",
dividend, divisor, result.Item1, result.Item2);
else
Console.WriteLine(@"{0} \ {1} = <Error>", dividend, divisor);

dividend = Int32.MaxValue; divisor = -2073;
result = IntegerDivide(dividend, divisor);
if (result != null)
Console.WriteLine(@"{0} \ {1} = {2}, remainder {3}",
dividend, divisor, result.Item1, result.Item2);
else
Console.WriteLine(@"{0} \ {1} = <Error>", dividend, divisor);
}

private static Tuple<int, int> IntegerDivide(int dividend, int divisor)
{
try {
int remainder;
int quotient = Math.DivRem(dividend, divisor, out remainder);
return new Tuple<int, int>(quotient, remainder);
}
catch (DivideByZeroException) {
return null;
}
}
}
// The example displays the following output:
//       136945 \ 178 = 769, remainder 63
//       2147483647 \ -2073 = -1035930, remainder 757
``````
``````Module modMain
Public Sub Main()
Dim dividend, divisor As Integer
Dim result As Tuple(Of Integer, Integer)

dividend = 136945 : divisor = 178
result = IntegerDivide(dividend, divisor)
If result IsNot Nothing Then
Console.WriteLine("{0} \ {1} = {2}, remainder {3}",
dividend, divisor, result.Item1, result.Item2)
Else
Console.WriteLine("{0} \ {1} = <Error>", dividend, divisor)
End If

dividend = Int32.MaxValue : divisor = -2073
result = IntegerDivide(dividend, divisor)
If result IsNot Nothing Then
Console.WriteLine("{0} \ {1} = {2}, remainder {3}",
dividend, divisor, result.Item1, result.Item2)
Else
Console.WriteLine("{0} \ {1} = <Error>", dividend, divisor)
End If
End Sub

Private Function IntegerDivide(dividend As Integer, divisor As Integer) As Tuple(Of Integer, Integer)
Try
Dim remainder As Integer
Dim quotient As Integer = Math.DivRem(dividend, divisor, remainder)
Return New Tuple(Of Integer, Integer)(quotient, remainder)
Catch e As DivideByZeroException
Return Nothing
End Try
End Function
End Module
' The example displays the following output:
'       136945 \ 178 = 769, remainder 63
'       2147483647 \ -2073 = -1035930, remainder 757
``````

## Hinweise

Der Typ der Item1 Komponente kann auf zwei Arten dynamisch bestimmt werden:You can dynamically determine the type of the Item1 component in one of two ways:

• Durch Aufrufen der- `GetType` Methode für den Wert, der von der-Eigenschaft zurückgegeben wird Item1 .By calling the `GetType` method on the value that is returned by the Item1 property.

• Durch Abrufen des Type Objekts, das das Tuple<T1,T2> Objekt darstellt, und Abrufen des ersten Elements aus dem Array, das von seiner-Methode zurückgegeben wird Type.GetGenericArguments .By retrieving the Type object that represents the Tuple<T1,T2> object, and retrieving the first element from the array that is returned by its Type.GetGenericArguments method.