如何转换Vb.net到c# [英] How to convert from Vb.net to c#

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

问题描述





如何将以下内容转换为c#:



Public Sub SelectAll2(ByVal sender As System.Object,ByVal e As System.EventArgs)处理dgDiscountingInvoicesEmpNames.SelectedIndexChanged



EndSub

Hi,

How to convert the below to c#:

Public Sub SelectAll2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dgDiscountingInvoicesEmpNames.SelectedIndexChanged

EndSub

推荐答案

你可以自动完成。为此目的提供在线服务,但您可以使用开源产品ILSpy以非常好的质量离线完成整个装配。请参阅我以前的回答:代码解释,C#到VB .NET [ ^ ]。



-SA
You can do it automatically. There are on-line services for this purpose, but you can do it off-line with very good quality to a whole assembly, using open-source product ILSpy. Please see my past answer: Code Interpretation, C# to VB.NET[^].

—SA


方法翻译为:



The method translates as:

public void SelectAll2(System.Object sender, System.EventArgs e)<br />
{<br />
}





在C#中相当于VB.Net的'句柄语法要求:



A.对定义了事件'SelectAll2的对象/类的实例的有效引用:



private dgDiscountingInvoicesEmpNames dIENames;



B.将EventHandler连接到实例





In C# the equivalent to VB.Net's 'Handles syntax requires:

A. a valid reference to an instance of an object/class for which the event 'SelectAll2 is defined:

private dgDiscountingInvoicesEmpNames dIENames;

B. wiring-up the EventHandler to the instance

// somewhere in your code:<br />
dIENames = new dgDiscountingInvoicesEmpNames(); <br />
dIENames += SelectAll2;





请注意,在VB中这个对象/类暴露的有效实例事件是通过实例化'WithEvents变量。



Note that in VB this valid instance of an object/class exposing the Event is done by instantiating a 'WithEvents variable.


这篇关于如何转换Vb.net到c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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