Does VB.NET have anonymous functions?

前端 未结 6 1536
陌清茗
陌清茗 2020-12-15 22:42

From what I can find on google, VB.NET only has one-statement lambdas, and not multi-statement anonymous functions. However, all the articles I read were talking about old v

6条回答
  •  我在风中等你
    2020-12-15 23:27

    This is inaccurate. VB.NET does in fact have anonymous methods. Here is an example:

    Private Function JsonToObject(Of T)(Value As String) As T
        Dim JavaScriptSerializer As New System.Web.Script.Serialization.JavaScriptSerializer()
        Return JavaScriptSerializer.Deserialize(Of T)(Value)
    End Function
    
    Dim People As Generic.List(Of Person) = JsonToObject(Of Generic.List(Of Person))(Json)
    

提交回复
热议问题