' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
﻿Imports System
Imports System.Collections.Generic

Namespace E
    Public Class Program
        Public Shared Sub Main(args As String())
            Dim lst As New List(Of Integer)() From { 1, 2, 3, 4 }
            Console.WriteLine(lst.Count)
            Dim i As Integer = 0
            While i < lst.Count
                If lst(i) = 1 Then
                    lst.Remove(lst(i))
                End If
                i = i + 1
            End While
            Console.WriteLine(lst.Count)
            Try
                For Each v As Integer In lst
                    If v = 2 Then
                        lst.Remove(v)
                    End If
                Next
            Catch ex As InvalidOperationException
                Console.WriteLine("Ooops")
            End Try
        End Sub
    End Class
End Namespace
