mercredi 24 juin 2015

Passing values within a string in a Condition [duplicate]

This question already has an answer here:

I have a set of rules that are as follows:

string[] rules = { "val>2", "2<val<10" };

or even:

string[] rules = { "val==true" };

And I want to pass this to an IF condition like this:

foreach(string rule in rules)
{
    if(rule)
    {
       //Code
    }
}

It's surprising that I couldn't find this question on google. Is this even possible? The Inverted commas in a string make it impossible to get this done. Is there a solution?

Aucun commentaire:

Enregistrer un commentaire