【发布时间】:2011-08-17 02:47:06
【问题描述】:
我有一个这样的集合
Private Shared ReadOnly thermoPaths As New ReadOnlyCollection(Of String) _
({
"thermometer_000_108x320.jpg",
"thermometer_010_108x320.jpg",
"thermometer_020_108x320.jpg",
"thermometer_030_108x320.jpg",
"thermometer_040_108x320.jpg",
"thermometer_050_108x320.jpg",
"thermometer_060_108x320.jpg",
"thermometer_070_108x320.jpg",
"thermometer_080_108x320.jpg",
"thermometer_090_108x320.jpg",
"thermometer_100_108x320.jpg"
})
并希望将 1 到 100 之间的十进制值链接到我收藏中的相应项目。
所以基本上我想要实现的就是这个。
Select Case Decimal.Round(value)
Case 1 To 9
Dim x As String = thermoPaths(0)
Case 10 To 19
Dim x As String = thermoPaths(1)
Case 20 To 29
Dim x As String = thermoPaths(2)
Case 30 To 39
Dim x As String = thermoPaths(3)
case ''AND SO ON
End Select
但我确定必须有一种“更清洁”的方式来做到这一点??
【问题讨论】:
标签: .net vb.net math collections rounding