VB.NET - Remove items from a list with RemoveAll

Опубликовано: 20 Март 2026
на канале: JFLHV
571
4

3 Examples of List.RemoveAll to filter a list of words in VB.NET

#vbdotnet

RemoveAll inline simple
fIlteredWords.RemoveAll (Function(str) str.Contains(filter)=False)

RemoveAll AddressOf existing function
fIlteredWords.RemoveAll (AddressOf ContainsVowel)

RemoveAll inline existing function 2 parameters
filteredWords.RemoveAll (Function(str) ContainsAllChars(str, filter)=False)

Public Function ContainsVowel(ByVal str As String)
Dim vowels As Char() = {"a", "e", "i", "o", "u"}
For Each c As Char In str
If vowels.Contains(c) Then
Return True
End If
Next
Return False
End Function

Public Function ContainsAllChars(ByVal str As String, ByVal chars As String)
For Each c As Char In chars
If str.Contains(c) = False Then
Return False
End If
Next
Return True
End Function