locked
Evaluating an expression using DataTable.Compute() method throws error RRS feed

  • Question

  • User1239236692 posted

    I'm trying to evaluate an expression using the Compute() method of DataTable and it shows an error "Cannot interpret token ?". My expression contains ternary operator and i need to solve the expression manually (without using nCalc or other tools). Is there any inbuilt microsoft functionality or any other approach to solve this expression.

    DataTable dt = new DataTable();
    var result = dt.Compute(" ( 1 > 20 ) ? (( 1 / 1 ) > 10 && ( 1 / 1 ) <= 3500 ) : (  ( 1 == 0) ? 1 : 0 )", null);
    Console.WriteLine("The result is" + result);
    Sunday, September 20, 2015 10:49 AM

Answers

All replies