使用 Javascript 到 C# 转换器的帮助
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3757245/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Help with Javascript to C# converter
提问by guaike
I find a algorithm writen by javascript,now i want to convert it to C#, Any tool can do this?
我找到了一个由 javascript 编写的算法,现在我想将它转换为 C#,任何工具都可以做到这一点?
回答by Tim Medora
Well, you could start with Javascript.Netto try your code within another application before rewriting/converting it. Whatever you do, don't rely on auto-generated code for an algorithm of any importance.
好吧,您可以从Javascript.Net开始,在重写/转换之前在另一个应用程序中尝试您的代码。无论您做什么,都不要依赖自动生成的代码来获取任何重要的算法。
If memory serves, there was actually a flavor of JavaScript that ran on the .Net CLR. I don't think it ever caught on.
如果没记错的话,实际上有一种 JavaScript 在 .Net CLR 上运行。我不认为它曾经流行过。
回答by Andrew Dementiev
Using javascript.net or jscript with .net Reflector, will save you brain and keyboard, may be
将 javascript.net 或 jscript 与 .net Reflector 一起使用,将节省您的大脑和键盘,可能是
回答by Anderson Green
There is a dialect of JavaScript called UnityScript that can be converted into C# using the UnityScript-to-C# converter.
有一种称为 UnityScript 的 JavaScript 方言,可以使用UnityScript-to-C# 转换器将其转换为 C# 。
I also wrote a tool called universal-transpilercan convert a small subset of JavaScript into C# and several other languages.
我还编写了一个名为Universal-transpiler的工具,可以将一小部分 JavaScript 转换为 C# 和其他几种语言。
Input in JavaScript:
在 JavaScript 中输入:
function add(a,b){
var g = [3,4,5];
return a+b+(g[0])+(g.length);
}
function divide(a,b){
return a/b;
}
Output in C# from universal-transpiler:
通用转译器的 C# 输出:
public static int add(int a,int b){
int[] g={3,4,5};
return a+b+(g[0])+(g.Length);
}
public static int divide(int a,int b){
return a/b;
}

