本文整理匯總了C#中System.Tuple<T1,T2,T3,T4>.Item1屬性的典型用法代碼示例。如果您正苦於以下問題:C# Tuple<T1,T2,T3,T4>.Item1屬性的具體用法?C# Tuple<T1,T2,T3,T4>.Item1怎麽用?C# Tuple<T1,T2,T3,T4>.Item1使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Tuple<T1,T2,T3,T4>
的用法示例。
在下文中一共展示了Tuple<T1,T2,T3,T4>.Item1屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
Tuple<string, int, double, double>[] temperatures =
{ Tuple.Create("New York, NY", 4, 61.0, 43.0),
Tuple.Create("Chicago, IL", 2, 34.0, 18.0),
Tuple.Create("Newark, NJ", 4, 61.0, 43.0),
Tuple.Create("Boston, MA", 6, 77.0, 59.0),
Tuple.Create("Detroit, MI", 9, 74.0, 53.0),
Tuple.Create("Minneapolis, MN", 8, 81.0, 61.0) };
// Display the array of 4-tuple objects.
Console.WriteLine("{0,41}", "Temperatures");
Console.WriteLine("{0,-20} {1,5} {2,4} {3,4}\n",
"City", "Month", "High", "Low");
foreach (var temperature in temperatures)
Console.WriteLine("{0,-20} {1,5} {2,4:N1} {3,4:N1}",
temperature.Item1,
DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(temperature.Item2 - 1),
temperature.Item3, temperature.Item4);
}
}
輸出:
Temperatures City Month High Low New York, NY Mar 61.0 43.0 Chicago, IL Jan 34.0 18.0 Newark, NJ Mar 61.0 43.0 Boston, MA May 77.0 59.0 Detroit, MI Aug 74.0 53.0 Minneapolis, MN Jul 81.0 61.0