How to filter a list in-place with VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Class Program
    Public Shared Sub Main()
        Dim numbers As List(Of Integer) = New List(Of Integer) From {
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
        }
        numbers.RemoveAll(Function(n) n Mod 2 <> 0)
			
        Console.WriteLine(String.Join(", ", numbers))
    End Sub
End Class



' run:
'
' 2, 4, 6, 8, 10, 12
'

 



answered Jul 13, 2025 by avibootz
...