You want the static method Delegate.CreateDelegate. Something like this:
myDelegate = (MyDelegate) Delegate.CreateDelegate(typeof(MyDelegate), mi); -- Ian Griffiths - DevelopMentor http://www.interact-sw.co.uk/iangblog/ > -----Original Message----- > From: Ryan Parlee > > I am wanting to create a delegate at runtime using reflection but am > unable > to get this working. Specifically, I would like to something like this: > > > foreach (MethodInfo mi in > this.GetType().GetMethods(BindingFlags.Instance)) > { > myDelegate = new MyDelegate(mi.MethodHandle) > myArray.Add(myDelegate); > } > > > The compiler complains that new MyDelegate() expects a method. Is there a > way to do what I want to do? =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles http://www.develop.com/courses/gaspdotnetls View archives and manage your subscription(s) at http://discuss.develop.com
