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

Michael Letterle michael.letterle at gmail.com
Thu Apr 2 11:20:52 EDT 2009


class Array
        def to_clr_arr
        arr = System::Array.CreateInstance self[0].class.to_clr_type,
System::Int32.pase(self.length.to_s)
        self.each_with_index { |r, i| arr[i] = r }
        return arr
    end
end

my_csharp_class_instance.call(%w(some array).map{|x|
x.to_clr_string}.to_clr_arr)

2009/4/2 Thibaut Barrère <thibaut.barrere at gmail.com>

> 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
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>


-- 
Michael Letterle
IronRuby MVP
http://blog.prokrams.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090402/9bb98072/attachment.html>


More information about the Ironruby-core mailing list