[Ironruby-core] How to instanciate a System::String[] from IronRuby?

Curt Hagenlocher curth at microsoft.com
Thu Apr 2 11:03:29 EDT 2009


I don't know if it's the easiest way, but this should work as a conversion:

x = ['a', 'b', 'c']
System::Array[System::String].new(x.map { |s| s.to_s.to_clr_string })

(Obviously, if you know that the elements are already Ruby strings, you can omit the "to_s".)

From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Thibaut Barrère
Sent: Thursday, April 02, 2009 7:36 AM
To: ironruby-core
Subject: [Ironruby-core] How to instanciate a System::String[] from IronRuby?

Hi,

while trying to call some C# code from IronRuby, I get this:

my_csharp_class_instance.call(%w(some array))

:0: can't convert Array into System::String[] (TypeError)

Is there some easy way to construct an array of System::String ? Or a conversion ?

cheers,

-- Thibaut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090402/66587491/attachment.html>


More information about the Ironruby-core mailing list