# Is it possible to yield C# code?

**URL:** <https://www.ruby-forum.com/t/is-it-possible-to-yield-c-code/199834>\
**Category:** IronRuby\
**Created:** [November 30, 2010, 12:06am UTC](https://www.ruby-forum.com/t/is-it-possible-to-yield-c-code/199834 "2010-11-30T00:06:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 30, 2010, 12:06am UTC](https://www.ruby-forum.com/t/is-it-possible-to-yield-c-code/199834/1 "2010-11-30T00:06:25Z")

</div>

I’m sorry if this is the wrong list. Please direct me if so.

This is not really something I’m losing sleep over but still I’m a  
fair bit curious to know if it’s possible to yield code that’s not  
Ruby from IronRuby. Is it?

The following C# gives me a wrong number of arguments (1 for 0)  
exception.

delegate void del(string s);  
…

var rt = Ruby.CreateRuntime();  
var eng = rt.GetEngine(“rb”);  
eng.Execute(@"  
class YieldTest  
def test  
yield ‘From IronRuby’  
end  
end  
");  
object test = eng.Runtime.Globals.GetVariable(“YieldTest”);  
dynamic t = eng.Operations.CreateInstance(test);  
t.test((del)(s =\> Console.WriteLine(s)));

See

> <https://stackoverflow.com/questions/4189955/calling-ironruby-from-c-with-a-delegate>

If this is not possible, is it then a kind of integration that is  
planned for future releases of IronRuby?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 30, 2010, 6:47pm UTC](https://www.ruby-forum.com/t/is-it-possible-to-yield-c-code/199834/2 "2010-11-30T18:47:07Z")

</div>

It is not possible today, it might be possible in future 🙂

BTW, I would suggest to use Action instead of defining your own  
delegate type.

Tomas
