Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to create initialize and print a list of objects with List<T> Class in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic
 
Public Class Car
    Public Property Name As String
    Public Property Price As Decimal 
End Class  
         
Public Module Module1
    Public Sub Main()
        Dim cars As New List(Of Car) From
        {
            New Car With {.Name = "New 2020 Honda HR‑V SUV", .Price = 30010},
            New Car With {.Name = "2020 Volvo XC60", .Price = 47400},
            New Car With {.Name = "2020 Audi Q3", .Price = 35695},
            New Car With {.Name = "2020 Nissan Murano", .Price = 32625}
        }
 
		For Each theCar As Car In cars
            Console.WriteLine(theCar.Name)
            Console.WriteLine(theCar.Price.ToString & " ")
            Console.WriteLine()
        Next
    End Sub
End Module
 
 
 
' run:
'
' New 2020 Honda HR‑V SUV
' 30010 
 
' 2020 Volvo XC60
' 47400 
 
' 2020 Audi Q3
' 35695 
 
' 2020 Nissan Murano
' 32625
' 
'

 



answered May 5, 2020 by avibootz
edited May 5, 2020 by avibootz

Related questions

1 answer 161 views
2 answers 174 views
1 answer 182 views
1 answer 176 views
3 answers 282 views
4 answers 343 views
...