[Ironruby-core] Calling a C# static from IronRuby

Shay Friedman shay.friedman at gmail.com
Fri Nov 13 14:06:29 EST 2009


I guess you can do that in two ways.

The first one is to add a statement in Ruby code:

class Object
  def mymethod(str)
    MyCSharpClass.mymethod(str)
  end
end

Or you can write an IronRuby extension in C# and make that class extend the
Object class.

Shay.

-- 
--------------------------------------------------
Shay Friedman
Author of IronRuby Unleashed
http://www.IronShay.com
Follow me: http://twitter.com/ironshay

On Fri, Nov 13, 2009 at 8:22 PM, Alexandre Mutel <lists at ruby-forum.com>wrote:

> Hi all,
> Is there any way to declare a C# static method accessible from IronRuby
> as a regular Ruby method?
> like:
> public class MyCSharpClass {
>  public static string mymethod(string test) {
>     return test + "yes";
>  }
> }
>
> in ironruby:
> puts mymethod("test")
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091113/785b7f19/attachment.html>


More information about the Ironruby-core mailing list