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
'