How to declare a nested function in VB.NET?

How to declare a nested function in VB.NET? For example, I want to do something like this:

Function one()
    Function two()
    End Function
End Function

However, this statement is not valid in VB.NET due to an open function.

+3
source share
2 answers

Are you asking how to write a lambda expression ?

A lambda expression is a function or subroutine without a name that can be used wherever a delegate is valid. Lambda expressions can be functions or routines and can be single-line or multi-line. You can pass values ​​from the current region to a lambda expression.

-, Function Sub, , . - .

, "Hello World!":

Dim outputString As Action(Of String) = Sub(x As String)
                                            Console.WriteLine(x)
                                        End Sub
outputString("Hello World!")

. : VB.NET Lambda Expression

+13

, .

  • have Function two , Function one.
  • , .
+1

Source: https://habr.com/ru/post/1784357/


All Articles