0
我想弄清楚如何检索存储在Person类中的值。问题在于,在定义Person类的实例后,我不知道如何在IronRuby代码中检索它,因为实例名称位于.NET部分。在IronRuby中检索访问器
/*class Person
attr_accessor :name
def initialize(strname)
self.name=strname
end
end*/
//We start the DLR, in this case starting the Ruby version
ScriptEngine engine = IronRuby.Ruby.CreateEngine();
ScriptScope scope = engine.ExecuteFile("c:\\Users\\ron\\RubymineProjects\\untitled\\person.rb");
//We get the class type
object person = engine.Runtime.Globals.GetVariable("Person");
//We create an instance
object marcy = engine.Operations.CreateInstance(person, "marcy");