将C#事件转换为VB.NET [英] Convert a C# event to VB.NET

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

问题描述

大家好,

我是C#的新手,因为我通常在VB.NET中开发

最近,我从供应商那里收到了一个演示SDK,但是它是用C#开发的.我设法转换了全部代码,除了一个我做不到的代码.下面是代码:

 公共 Form1()
{
   InitializeComponent();

   // 添加事件
   _xtractor.OnBulkReadID + =  _IHKRAREMEvents_OnBulkReadIDEventHandler(_xtractor_OnBulkReadID);
} 



谁能帮我解释一下并将其转换为VB.NET?

谢谢.

解决方案

使用 ^ ]

  AddHandler  xtractor.OnBulkReadID, AddressOf  _xtractor_OnBulkReadID 


您每次需要将C#转换为VB.NET时都无法提出这样的问题.您只需要学习VB.NET以及可能的一些C#.

要立即翻译,可以使用以下方法:

1)找到带有代码示例的适当的MSDN帮助页面.他们都有语言选择.从C#切换到VB.NET,然后返回以查看两种语言如何实现API的某些语法.在这种情况下,请参阅 http://msdn.microsoft.com/en-us/library/ms743596 .aspx#Y198 [ ^ ].

2)使用一些在线翻译工具.参见:
http://www.developerfusion.com/tools/convert/csharp-to-vb/ [ ^ ],
http://www.developerfusion.com/tools/ [ http://www.harding.edu/fmccown/vbnet_csharp_comparison. html [^ ].

查找更多信息: http://en.lmgtfy.com/?q = translate +%22c%23%22 +%22vb.net%22 [public Form1() { InitializeComponent(); // add events _xtractor.OnBulkReadID += new _IHKRAREMEvents_OnBulkReadIDEventHandler(_xtractor_OnBulkReadID); }



Can anyone please help me to explain and convert it to VB.NET?

Thanks.

解决方案

Use AddHandler[^]

AddHandler xtractor.OnBulkReadID, AddressOf _xtractor_OnBulkReadID


You cannot ask such question every time you need to translate anything from C# to VB.NET. You simply need to learn VB.NET and probably some of C#.

To get immediate translation, you can use the following methods:

1) Find appropriate MSDN help page with code sample. They all have language options. Switch from C# to VB.NET and back to see how some syntax of API is implemented in both language. In this case, see http://msdn.microsoft.com/en-us/library/ms743596.aspx#Y198[^].

2) Use some on-line translation tool. See:
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^],
http://www.developerfusion.com/tools/[^].

3) For syntax, try to use the following quick cheat sheet: http://www.harding.edu/fmccown/vbnet_csharp_comparison.html[^].

Find some more: http://en.lmgtfy.com/?q=translate+%22c%23%22+%22vb.net%22[^].

—SA


这篇关于将C#事件转换为VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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