i'm trying to create method that will display all methods that specific type has.
the code is:
public static void AllMethods(Type t)
{
var query = from x in t.GetMethods() select x;
foreach (var item in query)
Console.WriteLine(item.Name);
}
i tried another version of this:
public static void AllMethods(Type t)
{
MethodInfo[] m = t.GetMethods();
foreach (MethodInfo item in m)
Console.WriteLine(item.Name);
}
both versions compile, but when it come to pass a parameter, the NullReferenceException occurs:
static void Main(string[] args)
{
AllMethods(Type.GetType("Z")); // Z is a class name
Console.ReadLine();
}
i guess the solution is simple, but my brain now can't figure out it)
any suggestions?