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,761 questions

51,661 answers

573 users

How to use LINQ select query on a list of objects in VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq
Imports System.Collections.Generic

Namespace LinqSelect
    Module Program
        Sub Main(args As String())
            Dim StudentObj As New List(Of Student) From {
                New Student With {.StudentId = 1, .Name = "Artemis", .Marks = 81},
                New Student With {.StudentId = 2, .Name = "Arthur", .Marks = 92},
                New Student With {.StudentId = 3, .Name = "Emmett", .Marks = 78},
                New Student With {.StudentId = 4, .Name = "Milo", .Marks = 95},
                New Student With {.StudentId = 5, .Name = "Amelia", .Marks = 86},
                New Student With {.StudentId = 6, .Name = "Felicity", .Marks = 80},
                New Student With {.StudentId = 7, .Name = "Echo", .Marks = 98}
            }

            Dim result = From s In StudentObj
                         Select New With {
                             .SName = s.Name,
                             .SID = s.StudentId,
                             .SMarks = s.Marks
                         }

            For Each item In result
                Console.WriteLine("The StudentName is {0} ID is {1} Marks is {2}", item.SName, item.SID, item.SMarks)
            Next
        End Sub
    End Module

    Class Student
        Public Property StudentId As Integer
        Public Property Name As String
        Public Property Marks As Integer
    End Class
End Namespace



' run:
'
' The StudentName is Artemis ID is 1 Marks is 81
' The StudentName is Arthur ID is 2 Marks is 92
' The StudentName is Emmett ID is 3 Marks is 78
' The StudentName is Milo ID is 4 Marks is 95
' The StudentName is Amelia ID is 5 Marks is 86
' The StudentName is Felicity ID is 6 Marks is 80
' The StudentName is Echo ID is 7 Marks is 98
'

 



answered Dec 14, 2025 by avibootz
...