c# - Use Operator from array in IF statement -
i trying use operator selected array in if statement. code below cannot compile it. there anyway around ?
string[] operators = new string[]{"<",">","=","!="}; decimal value = convert.todecimal(values[j]); var operator1 = (operators[convert.toint32(iquerytypelist[k])]); int jjj = convert.toint32(ntestvaluelist[k]); if (value operator1 jjj) { isactive = true; } else { isactive = false; }
one way perform string comparison either if-else chain or switch statement. don't know exact syntax c#, consider following pseudocode:
if (operator1.equals("<")) isactive = value < jjj // etc.
Comments
Post a Comment