我正在创建一个程序,我的列表有问题,因为在这个列表中,我的程序存储文件,来自解析的json,但我不需要所有的theese文件,所以我想要删除它列表。我的代码:
For i = 0 To LibrariesList.Count - 1
'//Lwjgl beta disabled:\\'
If LibrariesList.Item(i).Contains("org.lwjgl.lwjgl:lwjgl:2.9.1-nightly-20130708-debug3") = True Then
LibrariesList.Item(i) = LibrariesList.Item(i).Replace("org.lwjgl.lwjgl:lwjgl:2.9.1-nightly-20130708-debug3", Nothing)
End If
If LibrariesList.Item(i).Contains("org.lwjgl.lwjgl:lwjgl_util:2.9.1-nightly-20130708-debug3") = True Then
LibrariesList.Item(i) = LibrariesList.Item(i).Replace("org.lwjgl.lwjgl:lwjgl_util:2.9.1-nightly-20130708-debug3", Nothing)
End If
If LibrariesList.Item(i).Contains("org.lwjgl.lwjgl:lwjgl-platform:2.9.1-nightly-20130708-debug3") = True Then
LibrariesList.Item(i) = LibrariesList.Item(i).Replace("org.lwjgl.lwjgl:lwjgl-platform:2.9.1-nightly-20130708-debug3", Nothing)
End If
'//Lwjgl 2.9.2-Beta disabled:\\'
If LibrariesList.Item(i).Contains("org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-20140822") = True Then
LibrariesList.Item(i) = LibrariesList.Item(i).Replace("org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-20140822", Nothing)
End If
If LibrariesList.Item(i).Contains("org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-20140822") = True Then
LibrariesList.Item(i) = LibrariesList.Item(i).Replace("org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-20140822", Nothing)
End If
If LibrariesList.Item(i).Contains("org.lwjgl.lwjgl:lwjgl-platform:2.9.2-nightly-20140822") = True Then
LibrariesList.Item(i) = LibrariesList.Item(i).Replace("org.lwjgl.lwjgl:lwjgl-platform:2.9.2-nightly-20140822", Nothing)
End If
Next
库列表作为列表,但我的代码没有删除 完全是字符串,不删除字符串索引。我想删除字符串,使用字符串索引,使libraryists.cont - 1。
我该怎么做?
答案 0 :(得分:2)
假设正在使用实际的List(Of String),在List上迭代向后并使用RemoveAt():
Dim NotAllowed() As String = {
"org.lwjgl.lwjgl:lwjgl:2.9.1-nightly-20130708-debug3",
"org.lwjgl.lwjgl:lwjgl_util:2.9.1-nightly-20130708-debug3",
"org.lwjgl.lwjgl:lwjgl-platform:2.9.1-nightly-20130708-debug3",
"org.lwjgl.lwjgl:lwjgl:2.9.2-nightly-20140822",
"org.lwjgl.lwjgl:lwjgl_util:2.9.2-nightly-20140822",
"org.lwjgl.lwjgl:lwjgl-platform:2.9.2-nightly-20140822"
}
For i As Integer = LibrariesList.Count - 1 To 0 Step -1
For Each entry As String In NotAllowed
If LibrariesList(i).Contains(entry) Then
LibrariesList.RemoveAt(i)
Exit For
End If
Next
Next