Vb.net 我应该使用什么收集方法?

Vb.net 我应该使用什么收集方法?,vb.net,Vb.net,我有一个文本文件,它看起来像这样 defabot:3215 defatank:2985 ludditus:29 compensate:355 moobot:805 maxi292003:63 doctorbarzhal:19 plaanz:4 manguuu:51 atntpc:19 immortalsofthemist:18 当我的应用程序打开时,我正在加载这个列表,将名称从数字中分离出来,并用它填充listview控件。我想在内存中维护列表,以便整个项目使用和操作 我需要与名字相关联的数字

我有一个文本文件,它看起来像这样

defabot:3215
defatank:2985
ludditus:29
compensate:355
moobot:805
maxi292003:63
doctorbarzhal:19
plaanz:4
manguuu:51
atntpc:19
immortalsofthemist:18
当我的应用程序打开时,我正在加载这个列表,将名称从数字中分离出来,并用它填充listview控件。我想在内存中维护列表,以便整个项目使用和操作

我需要与名字相关联的数字,这样当我搜索名字时,我知道他们有多少分。实现这一点最有效/最简单的方法是什么

谢谢。

使用
字典(字符串、整数)
。以下是一个例子:

Dim dict As New Dictionary(Of String, Integer)
For Each s As String In IO.File.ReadAllLines("filename")
  Dim a() As String = s.Split(":"c)
  Dim userName As String = a(0)
  Dim userPoints As Integer = Convert.ToInt32(a(1))
  dict.Add(userName, userPoints)
Next
使用
字典(字符串、整数)
。以下是一个例子:

Dim dict As New Dictionary(Of String, Integer)
For Each s As String In IO.File.ReadAllLines("filename")
  Dim a() As String = s.Split(":"c)
  Dim userName As String = a(0)
  Dim userPoints As Integer = Convert.ToInt32(a(1))
  dict.Add(userName, userPoints)
Next

最有效的方法是使用
字典(字符串,Int32)

您可以通过其键获取值:

Dim ludditus As Int32 = dict("ludditus")

最有效的方法是使用
字典(字符串,Int32)

您可以通过其键获取值:

Dim ludditus As Int32 = dict("ludditus")
字典(字符串,整数)。第二项总是整数吗?字典(字符串,整数)。第二项总是整数吗?