Lambda does not support no return value in variables
I am beginning to play with Lambdas and I came across something that I cannot figure out. I am iterating through my list and printing them to the screen using a lambda but I then tried to assign my lambda to a variable and I get an error.
Code Works:
Dim people As New List(Of Person)
people.Add(New Person With {.Age = 12, .Name = "Bob"})
people.Add(New Person With {.Age = 18, .Name = "Cindy"})
people.Add(New Person With {.Age = 13})
Console.WriteLine("Results:")
people.ForEach(Function(p As Person) Console.WriteLine("> Name = {0}, Age = {1}", p.Name, p.Age))
If I change the last line to this I get an error "Expression does not produce a value"
Dim js As Action(Of Person) = _
Function(p As Person) Console.WriteLine("> Name = {0}, Age = {1}", p.Name, p.Age)
people.ForEach(js)
I did find a bug report (291473) for this exact circumstance which was resolved as By Design.
I 'm sure that this is because I am not passing back a value or instance to be assigned to the var 'js'. But what stumps me is how can I use the lambda in place of System.Action? Is it because the lambda is compiled as a delegate?

