gpt4 book ai didi

.net - 如何在 VB.NET 中声明嵌套函数?

转载 作者:行者123 更新时间:2023-12-04 05:09:34 24 4
gpt4 key购买 nike

如何在 VB.NET 中声明嵌套函数?例如,我想做这样的事情:

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

但是这个语句在VB.NET中是无效的,因为函数没有关闭。

最佳答案

你是问怎么写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 subroutines and can be single-line or multi-line. You can pass values from the current scope to a lambda expression.

You create lambda expressions by using the Function or Sub keyword, just as you create a standard function or subroutine. However, lambda expressions are included in a statement.


例如,以下代码将打印“Hello World!”:
Dim outputString As Action(Of String) = Sub(x As String)
Console.WriteLine(x)
End Sub
outputString("Hello World!")
有关更多示例,请参见此处: VB.NET Lambda Expression

关于.net - 如何在 VB.NET 中声明嵌套函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4638423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com