[Mono-list] MethodInfo Reflection

Rodrigo B. de Oliveira rbo@acm.org
Fri, 3 Sep 2004 15:35:27 -0300


Hi Matthew!

Try this instead:

MethodInfo method =
typeof(System.IO.DirectoryInfo).GetMethod("GetDirectories", new Type[0]);

Cheers,
Rodrigo

PS: How come you're not using boo? ;-)

import System
import System.IO

method = typeof(DirectoryInfo).GetMethod("GetDirectories", array(Type, 0))
print(join(method.Invoke(DirectoryInfo("/home/rodrigob"), null), "\n"))

----- Original Message ----- 
From: "Matthew Metnetsky" <met@uberstats.com>
To: "Mono List" <mono-list@lists.ximian.com>
Sent: Friday, September 03, 2004 2:22 PM
Subject: [Mono-list] MethodInfo Reflection


> I have a piece of code that is supposed to take any method and reflect
> on and then invoke.  At the moment I'm trying to use
> System.IO.DirectoryInfo.GetDirectories() which happens to be overloaded
> once (search criteria).  I'm trying to following code to specify which I
> want, but Type.GetMethod() keeps returning null.  What might I be doing
> wrong below?
>
> ~ Matthew
>
> ================
> using System;
> using System.IO;
> using System.Reflection;
>
> public class Test
> {
>     public static void Main(string[] args)
>     {
>         Type type = typeof(DirectoryInfo);
>
>         MethodInfo m = type.GetMethod("GetDirectories",
>                                       new Type[1] {typeof(void)});
>         Console.WriteLine(m); // returns null !
>     }
> }
> ====
>