【发布时间】:2016-03-04 04:41:04
【问题描述】:
我希望能够从一个数组中读取一组特定的行,这些行与我在另一个数组中的某个名称相关
例如:
在名称数组中,我将“Ben”存储为名称,我想查看另一个数组是否也包含名称“Ben”,如果包含,它将添加“Ben”所在的每一行的分数提到
其他数组:
“本得到 5” “纳什得了 6” “本有 4 个” “乔什得到 1”
所以它只会将 5 和 4 相加得到 9
然后程序会将计算出的数字保存到一个列表中。
For Each n As String In commonNames 'for the example the commonNames array contains Ben"
If names.Contains(n) Then
'add each of their scores and divide by how many their are
End If
Next
Console.ReadLine()
For Each n As String In originames
'add each score to the user and divide by 1
任何帮助将不胜感激 :)
【问题讨论】:
-
这是continuation,是吗? ;)
-
是的,我基本上看一个数组是否包含与另一个数组相同的名称,并将其与另一个数组中的元素进行比较,每次在一行中提到“Ben”时,该行的分数是加在一起
-
我认为最好在这里有一个描述你的对象的类,比如
Person