1

I've created a MethodCallExpression that calls a function which returns a bool. My problem is to convert the MethodCallExpression somehow into a BinaryExpression.

Or otherwise stated, how can i construct this expression by hand:

Expression<Func<string, bool>> exp = x => x.Contains("test");

3
  • 4
    Give us more details. What binary expression would you like it to be? Nov 11, 2009 at 16:03
  • 3
    Hint: write a single-line specification. "Method MyConvert takes a MethodCallExpression and returns the equivalent BinaryExpression". Great. Now you have a spec for MyConvert. Now you need a spec for "equivalent". Write a single-line spec for that. Keep going until you have every ambiguous word in your specification clearly defined. Then write the code that implements that specification. Nov 11, 2009 at 16:38
  • Hi Eric, after some sleep and reading your comment I looked at the problem from a differnent angle. Somehow I got onto the route to use BinaryExpressions in my greater context. But as I see now, this is a false assumption and not necessary. I can use the more general Expression instead and problem solved. Thanks for your viewpoint!
    – MarioH
    Nov 12, 2009 at 7:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.