jeudi 8 septembre 2016

Multiple value for if-statiment

if my statement contains two conditions:

string searchx = "some string"; 

if ((searchx.Contains("a1")) || (searchx.Contains("a2")))
{
...
}

but how to get list of values with single variable for statement?

if I got a1, a2, a3, a4, a5, a6, a7, a8, a9...

can I do it somehow this way, seems it is wrong attempt:

var valueList = new List<string> { "a1", "a2", "a3", "a4"};

but just to explain what I want to do, so if any value exist under valueList, condition is accepted:

if (searchx.Contains(valueList)) 
{
...
}

the best if I can get multiple value return I guess or any other way to get statement with updated list of values through single variable of any other way, which can work for me this way

Aucun commentaire:

Enregistrer un commentaire