开发者

Tell if a child class ctor called the base class one

开发者 https://www.devze.com 2023-01-26 18:24 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消