How to remove the last value from a list in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Public Class Program
	Public Shared Sub Main()
        Dim list As List(Of String) = New List(Of String)() From {
			"vb.net",
            "c",
            "java",
            "python",
            "php"
        }

        If list.Count > 0 Then
            list.RemoveAt(list.Count - 1)
        End If

        Console.WriteLine(String.Join(" ", list))
    End Sub
End Class




' run:
'
' vb.net c java python
'

 



answered Aug 7, 2023 by avibootz
...