The below code will show the way to use String Interpolation inside Statement Lambda using VB.Net
Imports System.Collections.Generic
Imports System.Linq
Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim personData = New List(Of PersonMaster)()
'populating some data
Enumerable.Range(1, 10).ToList().ForEach(Function(i) personData.Add(New PersonMaster() With { _
Key .PersonID = i, _
Key .PersonName = String.Concat("Person ", i), _
Key .Age = 14 + i _
}))
'Use of Statement Lambda
Dim eligiblePersonData = New List(Of EligiblePerson)()
personData.ToList().ForEach(Function(i)
Select Case If(i.Age < 18, 0, 1)
Case 0
'note the usage of String Interpolation - a feature of C# 6.0
Dim toDisplay As String = "Mr. {i.PersonName} is not eligible to case vote as his age is {i.Age} which is under 18"
Console.WriteLine(toDisplay)
Exit Select
Case 1
eligiblePersonData.Add(New EligiblePerson() With { _
Key .PersonID = i.PersonID, _
Key .PersonName = i.PersonName, _
Key .Age = i.Age _
})
Exit Select
End Select
End Function)
Console.ReadKey()
End Sub
End Class
'The main person model
Public Class PersonMaster
Public Property PersonID() As Integer
Get
Return m_PersonID
End Get
Set
m_PersonID = Value
End Set
End Property
Private m_PersonID As Integer
Public Property PersonName() As String
Get
Return m_PersonName
End Get
Set
m_PersonName = Value
End Set
End Property
Private m_PersonName As String
Public Property Age() As Integer
Get
Return m_Age
End Get
Set
m_Age = Value
End Set
End Property
Private m_Age As Integer
End Class
'Eligible Person Model
Public Class EligiblePerson
Public Property PersonID() As Integer
Get
Return m_PersonID
End Get
Set
m_PersonID = Value
End Set
End Property
Private m_PersonID As Integer
Public Property PersonName() As String
Get
Return m_PersonName
End Get
Set
m_PersonName = Value
End Set
End Property
Private m_PersonName As String
Public Property Age() As Integer
Get
Return m_Age
End Get
Set
m_Age = Value
End Set
End Property
Private m_Age As Integer
End Class
End Namespace