Welcome to collectivesolver - Programming & Software Q&A with Examples. A website you can trust. All programs tested and work.

Contact: aviboots(AT)netvision.net.il

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Dental Dog Chews

GlucoTrust is a brand new, science-backed supplement that supports healthy blood sugar levels AND weight loss for men and women

Everything you need to sell anywhere

Managed VPS Hosting
Affordable. Secure. Your Own Virtual Private Hosting. Faster than AWS and Rackspace

Bonsai Boy of New York Bonsai Trees and Accessories

Disclosure We are a professional Programming & Software Q&A website, that receives compensation from some of the links whose we show you with Information. It means that my content may contain affiliate links.

24,887 questions

32,502 answers

573 users

How to create a list of objects in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Public Class program
    Private name As String
    Private age As Integer
    Private programming As String

    Public Sub New(ByVal name As String, ByVal age As Integer, ByVal programming As String)
        Me.name = name
        Me.age = age
        Me.programming = programming
    End Sub

    Public ReadOnly Property OName As String
            Return name
        End Get
    End Property

    Public ReadOnly Property OAge As Integer
            Return age
        End Get
    End Property

    Public ReadOnly Property OProgramming As String
            Return programming
        End Get
    End Property
End Class

Public Class main
    Public Shared Sub Main()
        Dim list As List(Of program) = New List(Of program)()
		list.Add(New program("Liam", 45, "vb.ent"))
        list.Add(New program("Noah", 39, "java"))
        list.Add(New program("Emma", 51, "python"))

        For Each item In list
            Console.WriteLine("{0} - {1} - {2}", item.OName, item.OAge, item.OProgramming)
    End Sub
End Class

' run
' Liam - 45 - vb.ent
' Noah - 39 - java
' Emma - 51 - python


answered 2 days ago by avibootz