.net - Use reflection to determine which base class constructor is called -


Using the image on the type , we can determine: a) It It uses the public class base class {public base class} {} public base class (string some parameter) {}} public class DerivedClassA: base class {public DerivedClassA () {}} public class DerivedClassB: base class {public DerivedClassB (): Base ("canWindFindThis") {}}

< Strong> a) Yes. If you read information from ConstructorInfo.GetMethodBody () but without a supporting library like Mono Cecil, technically, you can find out which other consultants are called, One decode will have to be byte array.

b) In your case, yes, but generally no one can use reflection only to display on static data, runtime is not a dynamic state , So you will not be able to use it, to know which value was passed as a constructor in the form of a parameter, unless it is really specified as such, in which case you have ConstructorInfo .GetMethodBody () Received Mono.Cecil.

with the same technique

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -