C# to VB: Class.Event += (sender, args) => FunctionName(params)

前端 未结 3 923
无人及你
无人及你 2021-01-21 11:08

I\'m trying to convert the C# code from this webpage to VB.

Everything seems to have converted pretty much fine using an online converter tool, but then I reach the foll

相关标签:
3条回答
  • 2021-01-21 11:28
    AddHandler fadeOutAnimation.Completed, Sub() 
        OnFadeOutAnimationCompleted(d, hostGrid, grid)
    End Sub
    

    It's been a while, but since you're not using the parameters in the Event Handler I don't think you need to include them (because of Relaxed Delegate Conversion). If so, it'll look more like:

    AddHandler fadeOutAnimation.Completed, Sub(sender as object, args as EventArgs) 
        OnFadeOutAnimationCompleted(d, hostGrid, grid)
    End Sub
    
    0 讨论(0)
  • 2021-01-21 11:42

    They keywork you have to look for is "lambda expression".

    0 讨论(0)
  • 2021-01-21 11:47

    This is a lambda expression. Let me see how to do this in VB...

    AddHandler fadeOutAnimation.Completed, Sub(sender, e) _
    (OnFadeOutAnimationCompleted(d, hostGrid, grid))
    
    0 讨论(0)
提交回复
热议问题