What do you think of multiline lambdas in VB 10

前端 未结 7 3129
抹茶落季
抹茶落季 2021-02-20 03:09

I was just watching a video on MSDN Channel 9 which can be found here, about some of the new features in Visual Basic 10. Now I like most of the new features, some of which hav

7条回答
  •  北恋
    北恋 (楼主)
    2021-02-20 03:44

    I can think of two reasons off the top of my head why I love it! Been waiting too long for this.

    First:

     Private Sub SomeMethod()
         Dim SomeVariable as String = "Some text."
    
         AddHandler SomeButton.Click, Sub()
                                          SomeVariable += " Some more text"
                                          MessageBox.Show(SomeVariable)
                                      End Sub
    

    Second:

     Private Sub SomeMethodRunningInAnotherThread()
         Me.Dispatcher.Invoke(Normal, Sub()
                                          'Do some other stuff '
                                          SomeTextBox.Text = "Test"
                                      End Sub)
     End Sub
    

提交回复
热议问题