I'm looking at the parameters of a method and extracting the types. I get back (for instance) "System.String&", because the parameter is an out parameter. I want to know whether the parameter is a String - but there doesn't seem to be a way of converting a String& to its non-ref counterpart.
Can anyone point me in the right direction?
Thanks!
Type.GetElementType
The Type of the object encompassed or referred to by the current array, pointer, or reference type, or null if the current Type is not an array or a pointer, or is not passed by reference, or represents a generic type or a type parameter in the definition of a generic type or generic method.
Example:
var stringRefType = typeof(string).MakeByRefType();
var stringType = stringRefType.GetElementType();
Console.WriteLine(stringType == typeof(string)); // True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With