Patrik Hägne Patrik Hägne - 1 year ago 147
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?

Answer Source
ParameterInfo[] parameters = myMethodInfo.GetParameters();
foreach(ParameterInfo parameter in parameters)
    bool isRef = parameterInfo.ParameterType.IsByRef;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download