Ian Gardner
2010-Jun-28 18:02 UTC
[Ironruby-core] Static method on a C# class extending a generic class
Sorry, confusing subject, but just a quick question. I wanted to make one of my C# classes generic, but I didn''t want to have to worry about rewriting code everywhere that class was used, so I created a default derived class that shared the same name that had my default generic type. So something like this: public class MyClass : MyClass<string> { public static string TestStringDerived = "World"; public static string TestFuncDerived() { return "World"; } } public class MyClass<T> { public static string TestString = "Hello"; public static string TestFunc() { return "Hello"; } } Then I found in IronRuby that everywhere I had used MyClass.TestFunc or MyClass.TestString no longer worked. In fact in the above example MyClass.TestFuncDerived and MyClass.TestStringDerived don''t work either. I have already found my solution. Simply by adding an empty generic parameter it will work. So, MyClass[].TestFunc or MyClass[].TestFuncDerived works. So, my question (just because I am curious) is whether there is some deeper reason as to why IronRuby does not assume I want an empty generic parameter (MyClass[]) when I just give it MyClass. Thanks! -- Posted via http://www.ruby-forum.com/.