I’m trying to figure out a way to build a conditional dynamically.
Here is my code so far:
var greaterThan = ">";
var a = 1;
var b = 2;
if (a Convert.ToOperator(greaterThan) b) {...}
I did read this post, but could not figure out how to implement some of the stuff: C# convert a string for use in a logical condition
Any advice is highly appreciated. Thanks.
I wasn’t going to post it, but thought that it might be of some help. Assuming of course that you don’t need the advanced generic logic in Jon’s post.
You could use the code like this, with
greaterThanbeing astringwith the wanted logic/operator.