以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何用 “”元素不能重复“”的集合来存储字符串? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=158136) |
-- 作者:guosheng -- 发布时间:2020/11/9 15:55:00 -- 如何用 “”元素不能重复“”的集合来存储字符串? output输出的结果:元素是重复的,怎么让集合元素不重复啊? Dim Lst As New List(Of String) Lst.Add( "电视机") Lst.Add("电冰箱") Lst.Add("电冰箱") Lst.Add("洗衣机") Lst.Add("洗衣机") For Each Value As String In Lst OutPut.Show(Value) Next [此贴子已经被作者于2020/11/9 15:56:06编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/11/9 16:01:00 -- 判断一下,如果重复就不添加了 Lst.Add("电冰箱") if Lst.contains("电冰箱") = false then Lst.Add("电冰箱")
|
-- 作者:guosheng -- 发布时间:2020/11/9 16:02:00 -- 集合好像是元素不能重复的吧,怎么能 添加进去相同元素啊。是vb的集合类型变量可以元素重复吗 |
-- 作者:有点蓝 -- 发布时间:2020/11/9 16:03:00 -- 集合肯定是可以重复的。 |