# C# Overloads and IronRuby Classes

**URL:** <https://www.ruby-forum.com/t/c-overloads-and-ironruby-classes/172106>\
**Category:** IronRuby\
**Created:** [July 14, 2009, 10:42pm UTC](https://www.ruby-forum.com/t/c-overloads-and-ironruby-classes/172106 "2009-07-14T22:42:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shayfriedman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@shayfriedman](https://www.ruby-forum.com/u/shayfriedman)\
**Post date:** [July 14, 2009, 10:42pm UTC](https://www.ruby-forum.com/t/c-overloads-and-ironruby-classes/172106/1 "2009-07-14T22:42:25Z")

</div>

Hi there,

The next scenario worked for me on older versions but now the behavior  
changed and I’d like to know if the change is a bug or by design.

This is my C# code:  
public class MyClass {  
public void A() { A(1); }  
public void A(int val) { A(val, “foo”); }  
public void A(int val, string str) { Console.WriteLine(“{0} - {1}”,  
val, str); }  
}

And now in IR:  
class IronRubyRulez \< MyClass; end  
test = IronRubyRulez.new  
test.a # Prints “1 - foo”  
test.a(5) # Prints “5 - foo”  
test.a(7, “boom”) # Prints “7 - boom”

So far so good… but now I’d like to override the method “a”:  
class IronRubyRulez \< MyClass  
def a  
super(12)  
end  
end  
test = IronRubyRulez.new  
test.a # Error! wrong number of arguments (2 for 0)

This worked on older versions and resulted with “12 - foo”.  
Bug or by design?

## Thanks! Shay.

Shay F.  
[http://www.ironshay.com](http://www.ironshay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)

---

<div class="post-metadata">

**Author:** ![shayfriedman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@shayfriedman](https://www.ruby-forum.com/u/shayfriedman)\
**Post date:** [July 15, 2009, 3:12am UTC](https://www.ruby-forum.com/t/c-overloads-and-ironruby-classes/172106/2 "2009-07-15T03:12:27Z")

</div>

Shay F. wrote:

> Hi there,  
> …code snipped…  
> This worked on older versions and resulted with “12 - foo”.  
> Bug or by design?

Besides compiling the C# file, and requiring the resulting library, I  
was able to run your code without modification.

Are you passing any special arguments to ir.exe when running the  
program?  
I am using the latest pre-compiled 0.6v from the codeplex site:  
[http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29640](http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29640)

Out of curiosity, you could try with a different method name, in case  
there is possibly a conflict somewhere with another “A”

If the forum allows me, I’ll be attaching the exact files I used from  
your example. Otherwise, I’ll email them to you.

---

<div class="post-metadata">

**Author:** ![shayfriedman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@shayfriedman](https://www.ruby-forum.com/u/shayfriedman)\
**Post date:** [July 15, 2009, 8:40am UTC](https://www.ruby-forum.com/t/c-overloads-and-ironruby-classes/172106/3 "2009-07-15T08:40:20Z")

</div>

Well, I tried again and it now works… can’t tell what was wrong the  
other day…

Thanks for the help!  
Shay.
