How to print a list in VB.NET

3 Answers

0 votes
Imports System
Imports System.Collections.Generic

Public Class Program
    Public Shared Sub Main()
        Dim list As New List(Of Integer)
        
		list.Add(4)
        list.Add(6)
        list.Add(99)
        list.Add(3)        
		list.Add(1)

        For Each n As Integer In list
            Console.WriteLine(n)
        Next
    End Sub
End Class



' run:
'
' 4
' 6
' 99
' 3
' 1
'

 



answered Jan 2, 2022 by avibootz
edited Sep 17, 2022 by avibootz
0 votes
Imports System
Imports System.Collections.Generic

Public Class Program
    Public Shared Sub Main()
        Dim list As New List(Of Integer)
        
		list.Add(4)
        list.Add(6)
        list.Add(99)
        list.Add(3)        
		list.Add(1)

        For i As Integer = 0 To list.Count - 1
            Console.WriteLine(list.Item(i))
        Next i
    End Sub
End Class



' run:
'
' 4
' 6
' 99
' 3
' 1
'

 



answered Jan 2, 2022 by avibootz
edited Dec 27, 2023 by avibootz
0 votes
Imports System
Imports System.Collections.Generic
 
Public Class Program
    Public Shared Sub Main()
        Dim list As New List(Of Integer)
         
        list.Add(4)
        list.Add(6)
        list.Add(99)
        list.Add(3)        
        list.Add(1)
 
        Console.WriteLine(String.Join(", ", list))
    End Sub
End Class
 
 
 
' run:
'
' 4, 6, 99, 3, 1
'	

 



answered Sep 17, 2022 by avibootz

Related questions

1 answer 97 views
1 answer 127 views
1 answer 251 views
251 views asked Nov 14, 2021 by avibootz
1 answer 240 views
240 views asked Mar 10, 2021 by avibootz
1 answer 179 views
...