Another Lambda Expression Problem
-
Hello again, it seems that code translation tools have their problems with Lambda expressions – different from my own :( but still ... Maybe you can help me again: C#-code
EventHandler local = this.MailPopped;
if (local != null){local(this, new MailPoppedEventArgs(index, message, size, uidl, receivedTime));}has been translated to VB.NET this way:
Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
If local IsNot Nothing Then local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))The resulting error message reminds me that 'MailPopped' is an event so that a 'RaiseEvent' construction is needed. But which would be a proper syntax for the above expression? :confused: Thank you in advance Mick
-
Hello again, it seems that code translation tools have their problems with Lambda expressions – different from my own :( but still ... Maybe you can help me again: C#-code
EventHandler local = this.MailPopped;
if (local != null){local(this, new MailPoppedEventArgs(index, message, size, uidl, receivedTime));}has been translated to VB.NET this way:
Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
If local IsNot Nothing Then local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))The resulting error message reminds me that 'MailPopped' is an event so that a 'RaiseEvent' construction is needed. But which would be a proper syntax for the above expression? :confused: Thank you in advance Mick
It would look something like this
Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
RaiseEvent local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
-
It would look something like this
Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
RaiseEvent local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
-
Hello again, it seems that code translation tools have their problems with Lambda expressions – different from my own :( but still ... Maybe you can help me again: C#-code
EventHandler local = this.MailPopped;
if (local != null){local(this, new MailPoppedEventArgs(index, message, size, uidl, receivedTime));}has been translated to VB.NET this way:
Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPopped
If local IsNot Nothing Then local(Me, New MailPoppedEventArgs(index, message, size, uidl, receivedTime))The resulting error message reminds me that 'MailPopped' is an event so that a 'RaiseEvent' construction is needed. But which would be a proper syntax for the above expression? :confused: Thank you in advance Mick
You'll need to use the hidden VB event field (add "Event" to the event name):
Dim local As EventHandler(Of MailPoppedEventArgs) = Me.MailPoppedEvent
David Anton Convert between VB, C#, C++, & Java www.tangiblesoftwaresolutions.com