且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎么能在VB.NET中更改此代码

更新时间:2023-02-16 20:56:54

在每种特殊情况下回答这些问题都不好,太多了他们可以自动将任何C#代码翻译成VB.NET,反之亦然。



您可以使用Reflector或其开源替换ILSpy或类似工具之一:

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

http://ilspy.net/ [ ^ ]。



此外,这是有效的工具之一学习CIL。它可能非常有用,而且我不太了解这种语言。 CIL知识非常重要,尤其是使用 System.Reflection.Emit ,这是一个非常强大的库。



您可以用一种语言编写代码,编译代码,使用ILSpy加载程序集,选择其他语言,并反编译您需要的代码部分。结果的准确性非常好。



这是一个独立的开源代码转换器: http://codeconvert.codeplex.com/ [ ^ ]。



有许多在线工具:

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

http://converter.telerik.com/ [ ^ ](根据我的观察,这个更好)。



你可以找到更多:http://bit.ly/XFdX2G [ ^ ]。



我在一些更复杂的情况下,准确性可能会有问题。



-SA


你可以想做一些阅读:





  1. Marking-a-class-static-in-vb-net [ ^ ]
  2. vbnet_csharp_comparison.html [ ^ ]
  3. VB.NET和C#的完整比较 [ ^ ]





问候,

- Manfred


Public NotInheritable Class UnaryFunctions

Private Sub New()

End Sub

公共共享功能标识()为UnaryFunction

返回新的UnaryFunction(函数(x为双)x)

结束函数

结束类

public static class UnaryFunctions
    {
        public static UnaryFunction Identity() {
            return new UnaryFunction(delegate(double x) { return x; });
        }
     }



I''d like to change this code(original in C#) to VB.NET however i have no idea how to do it. Could someone help me?
Thanks

It''s not good to answer such questions in each particular situation, there are too many of them.

You can translate any C# code to VB.NET and visa versa by yourself, automatically.

You can use Reflector or its open-source replacement ILSpy or one of similar tools:
http://en.wikipedia.org/wiki/.NET_Reflector[^],
http://ilspy.net/[^].

Additionally, this is one of effective tools to learn CIL. It can be very useful, and I don''t know a good reference on the language. CIL knowledge is very important, in particular, for using System.Reflection.Emit, an extremely powerful library.

You can write code in one language, compile it, load the assembly with ILSpy, choose another language, and decompile the code part you need. The accuracy of the results is very good.

This is a stand-along open-source code convertor: http://codeconvert.codeplex.com/[^].

There is a number of on-line tools:
http://www.developerfusion.com/tools/convert/vb-to-csharp/[^],
http://converter.telerik.com/[^] (in my observations, this one is better).

You can find more: http://bit.ly/XFdX2G[^].

In some more complex cases, the accuracy can be questionable.

—SA


You may want to do some reading:


  1. Marking-a-class-static-in-vb-net[^]
  2. vbnet_csharp_comparison.html[^]
  3. Complete Comparison for VB.NET and C#[^]



Regards,

— Manfred


Public NotInheritable Class UnaryFunctions
Private Sub New()
End Sub
Public Shared Function Identity() As UnaryFunction
Return New UnaryFunction(Function(x As Double) x)
End Function
End Class