Say we have these two classes:
public class Derived : Base { public Derived(string s) : base(s) { } } public class Base { protected Base(string s) { } }
How can I find out from the Base constructor that Derived is an invoker? Here is what I came up with:
public class Derived : Base { public Derived(string s) : base(typeof(Derived), s) { } } public class Base { protected Base(Type type, string s) { } }
Is there another way that does not require passing typeof(Derived) , for example, somehow using reflection inside the Base constructor?
inheritance reflection c # types
core Jun 09 '09 at 21:03 2009-06-09 21:03
source share