// boilerplate (paste into LINQPad)
void Main()
{
int bar;
MethodWithParameters(1, out bar);
Console.WriteLine( bar );
}
void MethodWithParameters( int foo, out int bar ){
bar = 123;
var parameters = MethodInfo.GetCurrentMethod().GetParameters();
foreach( var p in parameters )
{
if( p.IsOut ) // the important part
{
Console.WriteLine( p.Name + " is an out parameter." );
}
}
}
This method depends on an optional metadata flag. This flag can be inserted by compilers, but the compilers are not obligated to do so.
This method utilizes the Out flag of the ParameterAttributes enumerator.