vendredi 21 décembre 2018

Method out/ref parameter basetype

I'm digging around in C# reflection but have encountered a problem.

If I reflect over the following method with the intent of retrieving the parameter types, then i'm unable to get the base type when the parameter have either the out or ref:

public void MyMethod(out int first, ref string second) {  }

The two parameter types returned are:

System.Int32&
System.String&

How do i get the base method in code, that is without the Ampersand postfixed?

Here are the boiled down way i retrieve the parameters:

typeof(MyClass).GetMethod(MyMethod().GetParameters().Select(p => p.ParameterType)





Aucun commentaire:

Enregistrer un commentaire