Tell if a child class ctor called the base class one
How do you programmatically find out if the ctor of a 开发者_如何学编程class invoked its base class ctor and with what arguments?
A derived class constructor always calls a base class constructor. This is required by the C# language specification.
To find out what arguments are passed, you might be able to ask the base class, if it saved them, but there is no universal way to do it.
Finding out which base class constructor got called is impossible for all code I've ever seen. The base class would have to save that information explicitly, but typically different constructors just use default values for some internal data.
精彩评论