将列表添加到vb.net中的另一个列表 [英] add a list into another list in vb.net

查看:77
本文介绍了将列表添加到vb.net中的另一个列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个如下列表,我想将其添加到另一个列表中:

I have a list as follows and I want to add it in another list:

Dim listRecord As New List(Of String)
listRecord.Add(txtRating.Text)
listRecord.Add(txtAge.Text)
listRace.Add(listRecord)  

要获得类似{{r1,a1},{r2,a2},{r3,a3}}之类的东西,如何在VB.Net中实现?

to obtain something like {{r1,a1},{r2,a2},{r3,a3}}, how can I achieve this in VB.Net?

推荐答案

我从您的问题中假设您要嵌套列表,而不是简单地将一个列表附加到另一个列表的末尾?

I assume from your question you want nested Lists, not to simply append one list onto the end of another?

Dim listRecord As New List(Of String)
listRecord.Add(txtRating.Text)
listRecord.Add(txtAge.Text)
listRace.Add(listRecord)

Dim records as new List(of List(of String))
records.Add(listRecord)

希望这会有所帮助

更新
阅读它们就像访问其他列表一样.
要获得第一条记录中的第一个字段

Update
Reading them is like accessing any other list.
To get the first field in the first record

return records(0)(0)

第一条记录中的第二个字段

second field in first record

return records(0)(1)

等. .

这篇关于将列表添加到vb.net中的另一个列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆