How to add the first element of a list to another list in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Class Program
    Public Shared Sub Main()
        Dim source As List(Of String) = New List(Of String) From {
            "aaa",
            "bbb",
            "ccc"
        }
        Dim target As List(Of String) = New List(Of String) From {
            "ddd"
        }

        If source.Count > 0 Then
            target.Add(source(0))
        End If

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



' run:
'
' ddd, aaa
'

 



answered Oct 16, 2025 by avibootz
...