zoukankan      html  css  js  c++  java
  • VB.NET中lambda的写法

    lambda 或者叫匿名方法

     1 '有返回值的匿名函数,func前面输入参数,最后一个输出参数
     2         Dim func1 As Func(Of Integer, Integer) = Function(ByVal i As Integer)
     3                                                      Return i + 1
     4                                                  End Function
     5         Dim func2 As Func(Of Integer, Integer, Integer) = Function(ByVal i As Integer, ByVal t As Integer)
     6                                                               Return i * t
     7                                                           End Function
     8         Dim func3 As Func(Of Integer, Integer, String) = Function(ByVal i As Integer, ByVal t As Integer)
     9                                                              Return (i * t).ToString
    10                                                          End Function
    11         '无返回值的函数
    12         Dim act1 As Action(Of String) = Sub(ByVal name As String)
    13                                             Console.Write("hello," + name)
    14                                         End Sub
    15         Console.WriteLine(func1.Invoke(4))
    16         Console.WriteLine(func2.Invoke(2, 3))
    17         Console.WriteLine(func3.Invoke(2, 3))
    18         act1.Invoke("bob")
  • 相关阅读:
    [NOI2004] 郁闷的出纳员
    对象内部套嵌多个对象
    函数
    匿名函数、对象
    函数部分
    Html部分
    搜索二叉树的应用
    二叉树的线索化
    搜索结构搜索二叉树
    堆与最优级队列
  • 原文地址:https://www.cnblogs.com/evening/p/5139494.html
Copyright © 2011-2022 走看看