C#的整合,F#,IronPython和IronRuby的 [英] Integration of C#, F#, IronPython and IronRuby

查看:173
本文介绍了C#的整合,F#,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 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.

这篇关于C#的整合,F#,IronPython和IronRuby的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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