asp.net - how to use if condition with string inside the condition using c# -


the values comes xml, user declare condition do.

string condition ="25<10"; 

now, want use in if condition like:

if(condition) {     //my condition } 

and getting error

cannot implicitly convert type string bool 

can tell me how this?

if provided conditions not complex, can try old trick datatable:

https://msdn.microsoft.com/en-us/library/system.data.datatable.compute(v=vs.110).aspx

private static bool computecondition(string value) {   using (datatable dt = new datatable()) {     return (bool)(dt.compute(value, null));   } }  ...  string condition ="25<10";   if (computecondition(condition)) {    //my condition   } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -