vendredi 2 octobre 2015

Reflection, ParameterInfo Short ParameterType [duplicate]

This question already has an answer here:

In Java, is is possible to get the "short" identifier for an object type, i.e. without the package affix. In C#, there is some really cool stuff you can do with reflection and methods, particularly with respect to the parameters.

I am trying to get the "short" parameter type from a parameter; however, so far, I have only been able to grab the fully qualified type. Is there a way to grab the short type without performing a substring-oriented operation on the type identifier?

For reference, here is how to get the parameter type:

ParameterInfo parameterInfo = MethodBase.GetCurrentMethod().GetParameters();
parameterInfo[1].ParameterType.ToString(); // do what you want with it, log it, print it, etc. 

I have to log the information to a file; however, I don't want (or need) to reveal package information.





Aucun commentaire:

Enregistrer un commentaire