I coppied and pasted this example, and it seems to fail. Why is MethodBase null?
http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.isout.aspx
edit: here is a link to my code: http://img689.imageshack.us/img689/3453/94123952.png
Let me know where my copy & paste is wrong.
here is the code for those that cant view the image:
#region
using System;
using System.Reflection;
#endregion
namespace ConsoleApp
{
class parminfo
{
public static void mymethod(
int int1m, out string str2m, ref string str3m)
{
str2m = "in mymethod";
}
public static int Main(string[] args)
{
Console.WriteLine("\nReflection.Parameterinfo");
//Get the ParameterInfo parameter of a function.
//Get the type.
Type Mytype = Type.GetType("parminfo");
//Get and display the method.
MethodBase Mymethodbase = Mytype.GetMethod("mymethod");
Console.Write("\nMymethodbase = " + Mymethodbase);
//Get the ParameterInfo array.
ParameterInfo[] Myarray = Mymethodbase.GetParameters();
//Get and display the IsOut of each parameter.
foreach (ParameterInfo Myparam in Myarray)
{
Console.Write("\nFor parameter # " + Myparam.Position
+ ", the IsOut is - " + Myparam.IsOut);
}
return 0;
}
}
}