【发布时间】:2011-03-17 15:19:06
【问题描述】:
当我尝试使用 ruby 脚本修改 c# 字符串列表时,出现以下异常。
未处理的异常:System.ArgumentException:值“Scott”不是“System.String”类型,不能在此通用集合中使用。
c#
IList<string> names = new List<string>();
names.Add("scott");
names.Add("jason");
ScriptRuntime runtime = IronRuby.Ruby.CreateRuntime();
ScriptEngine engine = runtime.GetEngine("IronRuby");
ScriptScope scope = engine.CreateScope();
scope.SetVariable("names", names);
engine.ExecuteFile("test.rb", scope);
foreach (var name in names)
{
Console.WriteLine(name);
}
红宝石
names.map! { |item| item.capitalize}
【问题讨论】:
标签: c# ironruby dynamic-language-runtime