Reputation: 5213
So I have a MethodInfo
object m
that I'm testing and I want to extract the type of a parameter. For instance, I want "int"
and string
from the following.
public void SomeMethod ( int i, string s )
{
// ...
}
When I run
ParameterInfo pinf = m.GetParameters.FirstOrDefault(p => p.Name == "i");
then
ping.GetType().Name
it returns "RuntimeParameterInfo"
.
So what do I actually need to be doing to get "int"
?
This is an example I made up, but the idea comes from a unit test I'm writing.
Upvotes: 0
Views: 203
Reputation: 125620
Use ping.ParameterType.Name
instead.
ParameterInfo.ParameterType
PropertyGets the Type of this parameter.
Upvotes: 1