将c#按引用类型转换为匹配的非按引用类型

将c#按引用类型转换为匹配的非按引用类型,c#,reflection,C#,Reflection,我使用反射检查C#方法的参数。该方法有一些out参数,对于这些类型,我返回的类型为IsByRef=true。例如,如果参数声明为“out string xxx”,则该参数的类型为System.string&。有没有办法将System.String&转换回System.String?当然,解决方案不仅适用于System.String,而且适用于任何类型。使用 演示: 使用 演示: 介意我把标题从“引用”改为“通过引用”吗?介意我把标题从“引用”改为“通过引用”吗? using System; us

我使用反射检查C#方法的参数。该方法有一些out参数,对于这些类型,我返回的类型为IsByRef=true。例如,如果参数声明为“out string xxx”,则该参数的类型为System.string&。有没有办法将System.String&转换回System.String?当然,解决方案不仅适用于System.String,而且适用于任何类型。

使用

演示:

使用

演示:


介意我把标题从“引用”改为“通过引用”吗?介意我把标题从“引用”改为“通过引用”吗?
using System;
using System.Reflection;

class Test
{
    public void Foo(ref string x)
    {
    }

    static void Main()
    {
        MethodInfo method = typeof(Test).GetMethod("Foo");
        Type stringByRef = method.GetParameters()[0].ParameterType;
        Console.WriteLine(stringByRef);
        Type normalString = stringByRef.GetElementType();
        Console.WriteLine(normalString);        
    }
}