I have two delegates. I want to use reflection to load an assembly/classes and to go through each class to see if the static methods in the class match the delegates.
I got everything up to getting all the methodinfos but i can s开发者_如何学Goeem to find any method to check if it matches the delegate and i really dont want to try create and catch exceptions.
thanks
You could use the CreateDelegate method:
// The delegate type you want to match against
var delegateType = typeof(Func<int>);
// The method info
MethodInfo someMethodInfo = ...
var del = Delegate.CreateDelegate(delegateType, someMethodInfo, false);
if (del != null) {
// you've got a match
}
精彩评论