以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]如何将一个集合的空值移除?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=177072)

--  作者:moseser
--  发布时间:2022/5/8 15:24:00
--  [求助]如何将一个集合的空值移除?
比如有一个集合
list_1     [ a, b, c, ,d]
其中cd 之间有一个空值,我想把 集合变成  [a ,b, c, d]

if list_1.contains(nothing) then
list_1.remove(nothing)
endif   

??不知道该如何正确的表达 空值

好像这样并没有移除



--  作者:2900819580
--  发布时间:2022/5/8 15:46:00
--  
Dim v1() As String = {"中国", "", "美国", " ", "日本", "", "俄罗斯"}
Dim list_1 As New List(Of String)
list_1.AddRange(v1)
MessageBox.Show(list_1.Count)
Do While list_1.Contains(" ") OrElse list_1.Contains("")
    list_1.Remove("")
    list_1.Remove(" ")
Loop 
MessageBox.Show(list_1.Count)