问题描述
好的,我已经在网上搜索了近6个小时并且放弃了这个。
我使用网站上的代码片段来创建一个小C#应用程序。
我正在学习在VB.net中做同样的事情,最后写到下面(实际上将C#转换为VB.NET)
Ok, I've been searching online for almost 6 Hrs and Gave up on this.
I used a code snippet from a Website to create a Small C# Application.
I am learning to do the same in VB.net and finally ended up writing below ( Actually Converting C# to VB.NET)
Private Sub btnSearch_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnSearch.Click, btnSearch.Tap
Dim MyClient As New PatDemoService.GetPatDemoClient
MyClient.GetPatDemoCompleted += New EventHandler(Of GetPatDemoCompletedEventArgs)(AddressOf MyClient_GetPatDemoCompleted)
MyClient.GetPatDemoAsync(TextBox1.Text)
End Sub
Private Sub MyClient_GetPatDemoCompleted(sender As Object, e As GetPatDemoCompletedEventArgs)
lbPatData.ItemsSource = e.Result
End Sub
转换后,我在这里得到一个错误(在粗体的行上)。错误说
'公共事件GetPatDemoCompleted(发送者为对象,e为PatDemoService.GetPatDemoCompletedEventArgs)'是一个事件,不能直接调用。使用'RaiseEvent'语句来举起活动。
有人可以帮我解决这个问题吗?
After conversion, I Get an error Here( on the line where it is bold). Error says'Public Event GetPatDemoCompleted(sender As Object, e As PatDemoService.GetPatDemoCompletedEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
Can someone Help me out on this?
推荐答案
MyClient.GetPatDemoCompleted += New EventHandler(Of GetPatDemoCompletedEventArgs)(AddressOf MyClient_GetPatDemoCompleted)
我猜它应该已被翻译为:
I would guess that it should been translated to:
Addhandler MyClient.GetPatDemoCompleted, Addressof MyClient_GetPatDemoCompleted
这篇关于C#到VB.NET转换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!