VB.NET 9.0: Lambda Expression Function

If you want to use Lambda Expression as reusable function, you need to use Func. By using the Func we are actually calling in-build delegate.

So if you write

Dim sqr As Func(Of Double, Double) = Function(x) x * x

Then you can use it in you application to get the square of a number.

Console.WriteLine(sqr(2))

Console.WriteLine(sqr(8))

This could be used in multiple places with different parameter as you generally do with any function.

Namoskar!!!