I have a code that gets the metadata of a class that includes the class methods and their parameters. And then the detected ParameterInfo is passed to another method for some other manipulations based on each parameter datatype. Following is the pseudocode snippet about which I am asking the question:
static void TypeDetector (ParameterInfo p) {
switch (p.ParameterType)
{
case System.Int32:
do_something;
break;
case System.String:
do_something;
break;
default:
do_nothing;
break;
}
But I receive these compile error messages:
error CS0119: 'int' is a type, which is not valid in the given context (this error refers to case System.Int32)
error CS0119: 'string' is a type, which is not valid in the given context (and this error refers to case System.String)
I also changed "TypeDetector" method parameter from ParameterInfo to Type but I received:
'Type' does not contain a definition for 'ParameterType' and no accessible extension method 'ParameterType' accepting a first argument of type 'Type' could be found
Which the latter error message makes sense as I assume I should use ParameterInfo as the "TypeDetector" parameter. I wonder what I should change in my method?
Thanks.