VS2010中C#整合IronRuby学习笔记

1.下载IronRuby1.0(http://ironruby.codeplex.com/)

2.安装IronRuby1.0

3.VS2010创建Console程式,参考引用C:/Program Files/IronRuby 1.0/IronRuby*.dll,Microsoft.*.dll

4.Console代码如下

using System; using System.Collections.Generic; using System.Linq; using System.Text; using IronRuby; using IronRuby.Compiler; using IronRuby.Hosting; using IronRuby.Runtime; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; namespace IronRubyConsole { class Program { static void Main(string[] args) { var runtime = Ruby.CreateRuntime(); var engine = runtime.GetEngine("rb"); var scope = engine.CreateScope(); engine.Execute("puts 'Hello Ruby!'"); var rb = "say = 'I love Ruby!'/n" + "puts say/n" + "say['love'] = '*love*'/n" + "puts say.upcase/n" + "5.times { puts say }"; var code = engine.CreateScriptSourceFromString(rb, SourceCodeKind.Statements); code.Execute(scope); Console.ReadLine(); } } }

你可能感兴趣的:(c,String,C#,Class,Ruby,2010)