C#到VB.NET转换错误 [英] C# to VB.NET Conversion Error

查看:82
本文介绍了C#到VB.NET转换错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我已经在网上搜索了近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?

推荐答案

您没有显示源(C#)代码,因此我无法检查它。您也没有提供翻译的参考。一些在线翻译器比其他翻译器好。



此外,如果你可以花更多的时间进行编译和反编译,那么就有一个高质量的开放-source off-line选项,ILSpy。



请查看我过去的答案:

固定页面到ContentPage将c#代码转换为vb.net [ ^ ],

需要将vb代码转换为c# [ ^ ]。



-SA
You did not show the source (C#) code, so I cannot check it up. You also did not provide a reference to the translator. Some of the on-line translators are better than others.

Besides, if you can spend a bit more time on compilation and decompilation, there is a high-quality open-source off-line option, ILSpy.

Please see my past answers:
FixedPage to ContentPage convert c# code into vb.net[^],
Need to convert vb code to c#[^].

—SA


许多C#到VB转换器f可以正确翻译事件处理程序的连接。



根据您的指示行:



Many C# to VB converters fail to translate the wiring up of event handlers properly.

Based on your indicate line of:

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转换错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆