Ok ... in Objective-C, you can subclass from a static method in the base class using 'new this ()', because in the static method, 'this' refers to the class, not the instance. It was a pretty damn cool find when I first found it, and I used it often.
However, in C # this does not work. Heck!
So ... does anyone know how I can “update” a subclass from a static base class method?
Something like that...
public class MyBaseClass{
string name;
public static Object GimmeOne(string name){
return new this(name);
}
public MyBaseClass(string name){
this.name = name;
}
}
public class SubClass1 : MyBaseClass{ }
public class SubClass2 : MyBaseClass{ }
public class SubClass3 : MyBaseClass{ }
SubClass1 foo = SubClass1.GimmeOne("I am Foo");
And yes, I know that I can (and usually) just use the constructors directly, but we have a special need to call the common member in the base class, so I ask. Again, Objective-C let me do this. Hope C # too.
So ... any participants?