> There's only one potential problem with it: all the overloads with the
> boolean parameter are .NET 2.0 only.
Sure - but the following works on the 1.x & 2.0 runtimes (it's just
presumably slower for the 'false' case than the newer 2.0 versions):
static bool IsMethodCompatibleWithDelegate(
MethodInfo targetMethod,
Type delegateType
)
{
try {
return(Delegate.CreateDelegate(delegateType, targetMethod) != null);
}
catch {
return(false);
}
}
So you can use the above on any .NET platform and be assured of getting a
platform-specific correct answer. If you have the luxory of assuming >=
2.0, you can use the newer versions and presumably get a bit of a speedup
for scenarios where the answer is 'false'.
-Mike
Bear Canyon Consulting LLC
http://www.bearcanyon.com
http://www.pluralsight.com/mike
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com