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
Post a Comment