本文整理汇总了VB.NET中System.Tuple<T1,T2,T3,T4,T5>类的典型用法代码示例。如果您正苦于以下问题:VB.NET Tuple<T1,T2,T3,T4,T5>类的具体用法?VB.NET Tuple<T1,T2,T3,T4,T5>怎么用?VB.NET Tuple<T1,T2,T3,T4,T5>使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tuple<T1,T2,T3,T4,T5>类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Example
' 导入命名空间
Imports System.Collections.Generic
Module Example
Public Sub Main()
' Organization of runningBacks 5-tuple:
' Component 1: Player name
' Component 2: Number of games played
' Component 3: Number of attempts (carries)
' Component 4: Number of yards gained
' Component 5: Number of touchdowns
Dim runningBacks() =
{ Tuple.Create("Payton, Walter", 190, 3838, 16726, 110),
Tuple.Create("Sanders, Barry", 153, 3062, 15269, 99),
Tuple.Create("Brown, Jim", 118, 2359, 12312, 106),
Tuple.Create("Dickerson, Eric", 144, 2996, 13259, 90),
Tuple.Create("Faulk, Marshall", 176, 2836, 12279, 100) }
' Calculate statistics.
' Organization of runningStats 5-tuple:
' Component 1: Player name
' Component 2: Number of attempts per game
' Component 3: Number of yards per game
' Component 4: Number of yards per attempt
' Component 5: Number of touchdowns per attempt
Dim runningStats() = ComputeStatistics(runningBacks)
' Display the result.
Console.WriteLine("{0,-16} {1,5} {2,6} {3,7} {4,7} {5,7} {6,7} {7,5} {8,7}",
"Name", "Games", "Att", "Att/Gm", "Yards", "Yds/Gm",
"Yds/Att", "TD", "TD/Att")
Console.WriteLine()
For ctr As Integer = 0 To runningBacks.Length - 1
Console.WriteLine("{0,-16} {1,5} {2,6:N0} {3,7:N1} {4,7:N0} {5,7:N1} {6,7:N2} {7,5} {8,7:N3}",
runningBacks(ctr).Item1, runningBacks(ctr).Item2, runningBacks(ctr).Item3,
runningStats(ctr).Item2, runningBacks(ctr).Item4, runningStats(ctr).Item3,
runningStats(ctr).Item4, runningBacks(ctr).Item5, runningStats(ctr).Item5)
Console.WriteLine()
Next
End Sub
Private Function ComputeStatistics(players() As Tuple(Of String, Integer, Integer, Integer, Integer)) _
As Tuple(Of String, Double, Double, Double, Double)()
Dim result As Tuple(Of String, Double, Double, Double, Double)
Dim list As New List(Of Tuple(Of String, Double, Double, Double, Double))()
For Each player In players
' Create result object containing player name and statistics.
result = Tuple.Create(player.Item1,
player.Item3/player.Item2, player.Item4/player.Item2,
player.Item4/player.Item3, player.Item5/player.Item3)
list.Add(result)
Next
Return list.ToArray()
End Function
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:56,代码来源:Tuple 输出:
Name Games Att Att/Gm Yards Yds/Gm Yds/Att TD TD/Att
Payton, Walter 190 3,838 20.2 16,726 88.0 4.36 110 0.029
Sanders, Barry 153 3,062 20.0 15,269 99.8 4.99 99 0.032
Brown, Jim 118 2,359 20.0 12,312 104.3 5.22 106 0.045
Dickerson, Eric 144 2,996 20.8 13,259 92.1 4.43 90 0.030
Faulk, Marshall 176 2,836 16.1 12,279 69.8 4.33 100 0.035
注:本文中的System.Tuple<T1,T2,T3,T4,T5>类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论