我如何将此c#代码转换为vb.net? [英] How would I convert this c# code to vb.net?

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

问题描述

您好我在代码项目中找到了此代码,它似乎做了我想要的。不过它是用c#写的,我不熟悉。任何多语言程序员都可以将其转换为vb.net?非常感谢您给予的任何帮助!



Hello I found this code here on code project and it seems to do what I want. However it it written in c# which I'm not familiar with. Any polyglot programmers out there who can convert this to vb.net? I greatly appreciate any help you may give!

foreach (DataGridViewColumn clm in grdView.Columns)
{
    Bool FoundData = false;
    foreach (DataGridViewRow row in grdView.Rows)
    {
         if (row.Cells[clm.Index].Value.ToString() != string.Empty)
         {
             FoundData = true;
             break;
         }
    }
    if (!FoundData)
    {
         grdView.Columns[clm.Index].Visible = false;
    }
}

推荐答案

除了用于翻译的在线工具(解决方案1中引用的工具)似乎是最好的之一),有一个非常好的和全面的离线开源解决方案。



这是ILSpy:

http://www.ilspy.net/ [ ^ ],

http: //en.wikipedia.org/wiki/.NET_Reflector [ ^ ]。



首先,您需要编译项目并获得已编译的程序集。它编译为CIL:

http://en.wikipedia.org/wiki/Common_Intermediate_Language [ ^ ]。



您可以将程序集加载到ILSpy中并对其进行反汇编。它有输出语言选项。选择C#或VB.NET,然后重新编译所需的部分代码。你已经完成了。



您可以将整个程序集一次性反编译成一个完整的项目,包含所有源代码并随时可以使用Visual Studio。



祝你好运,

-SA
In addition to on-line tools for translation (the one referenced in Solution 1 seems to be one of the best), there is a really good and comprehensive off-line open-source solution.

This is ILSpy:
http://www.ilspy.net/[^],
http://en.wikipedia.org/wiki/.NET_Reflector[^].

First, you need to compile the project and obtain a compiled assembly. It is compiled to CIL:
http://en.wikipedia.org/wiki/Common_Intermediate_Language[^].

You can load assembly into ILSpy and disassemble it. It has the option for output language. Select either C# or VB.NET, and recompile the part of code you need. You are done.

You can decompile the whole assembly at once into a whole full project, complete with all source code and ready to use with Visual Studio.

Good luck,
—SA


你真的试过看吗为了它?如果您进行谷歌搜索,第一个结果将是:



http://www.developerfusion.com/tools/convert/csharp-to-vb/ [ ^ ]



这给了我这个结果:



Did you really try to look for it? If you do a Google search, the first result would be this:

http://www.developerfusion.com/tools/convert/csharp-to-vb/[^]

And that gives me this result:

For Each clm As DataGridViewColumn In grdView.Columns
	Dim FoundData As Bool = False
	For Each row As DataGridViewRow In grdView.Rows
		If row.Cells(clm.Index).Value.ToString() <> String.Empty Then
			FoundData = True
			Exit For
		End If
	Next
	If Not FoundData Then
		grdView.Columns(clm.Index).Visible = False
	End If
Next


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

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