當前位置: 首頁>>代碼示例>>C#>>正文


C# Tuple.Create方法代碼示例

本文整理匯總了C#中System.Tuple.Create方法的典型用法代碼示例。如果您正苦於以下問題:C# Tuple.Create方法的具體用法?C# Tuple.Create怎麽用?C# Tuple.Create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Tuple的用法示例。


在下文中一共展示了Tuple.Create方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1:

var primes = Tuple.Create(2, 3, 5, 7, 11, 13, 17, 19);
Console.WriteLine("Prime numbers less than 20: " + 
                  "{0}, {1}, {2}, {3}, {4}, {5}, {6}, and {7}",
                  primes.Item1, primes.Item2, primes.Item3, 
                  primes.Item4, primes.Item5, primes.Item6,
                  primes.Item7, primes.Rest.Item1);
開發者ID:.NET開發者,項目名稱:System,代碼行數:6,代碼來源:Tuple.Create

輸出:

Prime numbers less than 20: 2, 3, 5, 7, 11, 13, 17, and 19

示例2:

var primes = new Tuple<int, int, int, int, int, int, int, 
                 Tuple<int>>(2, 3, 5, 7, 11, 13, 16, 
                 new Tuple<int>(19));
開發者ID:.NET開發者,項目名稱:System,代碼行數:3,代碼來源:Tuple.Create

示例3:

var tuple7 = Tuple.Create("Jane", 90, 87, 93, 67, 100, 92);
Console.WriteLine("Test scores for {0}: {1}, {2}, {3}, {4}, {5}, {6}",
                  tuple7.Item1, tuple7.Item2, tuple7.Item3,
                  tuple7.Item4, tuple7.Item5, tuple7.Item6,
                  tuple7.Item7);
// Displays Test scores for Jane: 90, 87, 93, 67, 100, 92
開發者ID:.NET開發者,項目名稱:System,代碼行數:6,代碼來源:Tuple.Create

示例4:

var tuple7 = new Tuple<string, int, int, int, int, int, int>
                      ("Jane", 90, 87, 93, 67, 100, 92);
Console.WriteLine("Test scores for {0}: {1}, {2}, {3}, {4}, {5}, {6}",
                  tuple7.Item1, tuple7.Item2, tuple7.Item3,
                  tuple7.Item4, tuple7.Item5, tuple7.Item6,
                  tuple7.Item7);
// Displays Test scores for Jane: 90, 87, 93, 67, 100, 92
開發者ID:.NET開發者,項目名稱:System,代碼行數:7,代碼來源:Tuple.Create

示例5:

var tuple6 = Tuple.Create("Jane", 90, 87, 93, 67, 100);
Console.WriteLine("Test scores for {0}: {1}, {2}, {3}, {4}, {5}",
                  tuple6.Item1, tuple6.Item2, tuple6.Item3,
                  tuple6.Item4, tuple6.Item5, tuple6.Item6);
// Displays Test scores for Jane: 90, 87, 93, 67, 100
開發者ID:.NET開發者,項目名稱:System,代碼行數:5,代碼來源:Tuple.Create

示例6:

var tuple6 = new Tuple<string, int, int, int, int, int>
                      ("Jane", 90, 87, 93, 67, 100);
Console.WriteLine("Test scores for {0}: {1}, {2}, {3}, {4}, {5}",
                  tuple6.Item1, tuple6.Item2, tuple6.Item3,
                  tuple6.Item4, tuple6.Item5, tuple6.Item6);
// Displays Test scores for Jane: 90, 87, 93, 67, 100
開發者ID:.NET開發者,項目名稱:System,代碼行數:6,代碼來源:Tuple.Create

示例7:

var tuple5 = Tuple.Create("New York", 1990, 7322564, 2000, 8008278);
Console.WriteLine("{0}: {1:N0} in {2}, {3:N0} in {4}",
                  tuple5.Item1, tuple5.Item3, tuple5.Item2,
                  tuple5.Item5, tuple5.Item4);
// Displays New York: 7,322,564 in 1990, 8,008,278 in 2000
開發者ID:.NET開發者,項目名稱:System,代碼行數:5,代碼來源:Tuple.Create

示例8:

var tuple5 = new Tuple<string, int, int, int, int>
                      ("New York", 1990, 7322564, 2000, 8008278);
Console.WriteLine("{0}: {1:N0} in {2}, {3:N0} in {4}",
                  tuple5.Item1, tuple5.Item3, tuple5.Item2,
                  tuple5.Item5, tuple5.Item4);
// Displays New York: 7,322,564 in 1990, 8,008,278 in 2000
開發者ID:.NET開發者,項目名稱:System,代碼行數:6,代碼來源:Tuple.Create

示例9:

var tuple4 = Tuple.Create("New York", 32.68, 51.87, 76.3);
Console.WriteLine("{0}: Hi {1}, Lo {2}, Ave {3}",
                  tuple4.Item1, tuple4.Item4, tuple4.Item2,
                  tuple4.Item3);
// Displays New York: Hi 76.3, Lo 32.68, Ave 51.87
開發者ID:.NET開發者,項目名稱:System,代碼行數:5,代碼來源:Tuple.Create

示例10:

var tuple4 = new Tuple<string, double, double, double>
                      ("New York", 32.68, 51.87, 76.3);
Console.WriteLine("{0}: Hi {1}, Lo {2}, Ave {3}",
                  tuple4.Item1, tuple4.Item4, tuple4.Item2,
                  tuple4.Item3);
// Displays New York: Hi 76.3, Lo 32.68, Ave 51.87
開發者ID:.NET開發者,項目名稱:System,代碼行數:6,代碼來源:Tuple.Create

示例11:

var tuple3 = Tuple.Create("New York", 32.68, 51.87);
Console.WriteLine("{0}: lo {1}, hi {2}", 
                  tuple3.Item1, tuple3.Item2, tuple3.Item3);
// Displays New York: lo 32.68, hi 51.87
開發者ID:.NET開發者,項目名稱:System,代碼行數:4,代碼來源:Tuple.Create

示例12:

var tuple3 = new Tuple<string, double, double>
                      ("New York", 32.68, 51.87);
Console.WriteLine("{0}: lo {1}, hi {2}", 
                  tuple3.Item1, tuple3.Item2, tuple3.Item3);
// Displays New York: lo 32.68, hi 51.87
開發者ID:.NET開發者,項目名稱:System,代碼行數:5,代碼來源:Tuple.Create

示例13:

var tuple2 = Tuple.Create("New York", 32.68);
Console.WriteLine("{0}: {1}", tuple2.Item1, tuple2.Item2);
// Displays New York: 32.68
開發者ID:.NET開發者,項目名稱:System,代碼行數:3,代碼來源:Tuple.Create

示例14:

var tuple2 = new Tuple<string, double>("New York", 32.68);
Console.WriteLine("{0}: {1}", tuple2.Item1, tuple2.Item2);
// Displays New York: 32.68
開發者ID:.NET開發者,項目名稱:System,代碼行數:3,代碼來源:Tuple.Create


注:本文中的System.Tuple.Create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。