Patrik Hägne Patrik Hägne - 2 months ago 26
C# Question

Ref parameters and reflection

I'm not sure if I'm totally missing something here but I can't find any way to determine if a parameter is passed by reference or not by using reflection.

ArgumentInfo has a property "IsOut", but no "IsRef". How would I go about to get all reference parameters in a given MethodInfo?

ParameterInfo[] parameters = myMethodInfo.GetParameters();
foreach(ParameterInfo parameter in parameters)
    bool isRef = parameterInfo.ParameterType.IsByRef;