Expression.Call() to String.Equals() throws error
- by Sam
The following code:
var constant = Expression.Constant("find me", typeof(string));
// memberExpression evaluates to a string
var predicate = Expression.Call(memberExpression, "Equals", null, constant);
is throwing the error More than one method 'Equals' on type 'System.String' is compatible with the supplied arguments.
I'm guessing that's because there's Equals(Object) and Equals(String) - is there any way for me to specify which method I mean to use via the overload of Expression.Call() that takes an instance method name as a string?
Or do I have to make a special case for calls to Equals() to take a MethodInfo instead?