C#的整合,F#,IronPython和IronRuby的IronPython、IronRuby

由网友(是男人就站起来)分享简介:有人告诉我,从C#和F#源所做的汇编文件是可互操作的,因为它们被编译成.NET程序集。I was told that the assembly files made from C# and F# source is interoperable as they are compiled into .NET assemb...

有人告诉我,从C#和F#源所做的汇编文件是可互操作的,因为它们被编译成.NET程序集。

I was told that the assembly files made from C# and F# source is interoperable as they are compiled into .NET assembly.

Q1:这是否意味着C#中可以调用F#的功能,就像他们是C#功能 Q2:如何对IronPython和IronRuby的?我没有看到从IronPython的/ IronRuby的任何程序集DLL。 Q3:有没有简单的方法来使用IronPython的/ IronRuby的功能从C#或F#

在任何例如code将是巨大的。

Any example code would be great.

推荐答案

1)是的。用一个简单的例子,在F#中,我可以调用一个C#控制台应用程序的主要方法:

1) Yes. Using a simple example, in F#, I can invoke the main method of a C# console app:

open SampleApp

SampleApp.Program.Main([| "Hello"; "World" |])

2)对于DLR,我觉得事情有点不同。我相信这是你将如何执行Python(例如);

2) For the DLR, I think things are a bit different. I believe this is how you would execute Python (for example);

ScriptEngine engine = Python.CreateEngine();
ScriptSource script = engine.CreateScriptFromSourceFile("myPythonScript.py");
ScriptScope scope = engine.CreateScope();

script.Execute(scope);

我的语法可能会关闭一个位 - 但你应该能够得到的要点

My syntax may be off a bit - but you should be able to get the gist.

3)你需要下载一些特殊的德国航空航天中心的DLL - 然后引用它们在你的C#/ F#应用程序以进行互操作。他们应该可以从微软DLR网站。

3) You need to download some special DLR DLLs - and then reference them in your C# / F# application in order to be interoperable. They should be available from the Microsoft DLR site.

阅读全文

相关推荐

最新文章