C# &引用;未知方法“;在C中使用IronRuby#
你好,晚上好,希望有人能帮忙 我正在尝试获得某种脚本支持。我有以下代码,它执行一个ruby方法并返回结果。然而,它从IronRuby本身返回了一个“MethodNotFound错误”C# &引用;未知方法“;在C中使用IronRuby#,c#,ruby,ironruby,C#,Ruby,Ironruby,你好,晚上好,希望有人能帮忙 我正在尝试获得某种脚本支持。我有以下代码,它执行一个ruby方法并返回结果。然而,它从IronRuby本身返回了一个“MethodNotFound错误” var engine = IronRuby.Ruby.CreateEngine(); returnvalue = engine.Operations.InvokeMember(instance, method, arg).ToString(); 我正在运行以下ruby代码作为测试: class Plotlight
var engine = IronRuby.Ruby.CreateEngine();
returnvalue = engine.Operations.InvokeMember(instance, method, arg).ToString();
我正在运行以下ruby代码作为测试:
class Plotlight
def get_message(a)
res = "Hello- from Ruby " << a
res
end
def swapcase(a)
res = a.downcase
res
end
end
通过ir.exe
运行代码不会出现任何问题
我需要参考图书馆吗?如果需要,我该怎么做
希望有人能帮忙!多谢各位
亲切的问候,MarcoRuby字符串的语义与CLR字符串不兼容。特别是,它们是可变的。Ruby字符串和CLR字符串之间的互操作尚未完成,因此现在您需要显式地将CLR System.String转换为Ruby字符串对象——无论是在C#代码中还是在Ruby代码中 最简单的解决方案是如下定义swapcase:
def swapcase(a)
String.new(a).downcase
end
def swapcase(a)
String.new(a).downcase
end