value = 14000;
ternary string expression is "value > 20000 ? 200 : value > 15000 && value < 19999 ? 150 : 100 "
Ans should be 100
Is there any ways to evaluate expression?
value = 14000;
ternary string expression is "value > 20000 ? 200 : value > 15000 && value < 19999 ? 150 : 100 "
Ans should be 100
Is there any ways to evaluate expression?
You could use Scripting APIs to evaluate the expressions.
The scripting APIs enable .NET applications to instatiate a C# engine and execute code snippets against host-supplied objects and would require Microsoft.CodeAnalysis.CSharp.Scripting
package.
For example,
var globals = new Global();
var str = "value > 20000 ? 200 : value > 15000 && value < 19999 ? 150 : 100 ";
var result = await CSharpScript.EvaluateAsync(str,globals:globals);
Console.WriteLine(result);
Where Global is defined as
public class Global
{
public int @value = 14000;
}