c# - How to find multiple values in array? -
my code below looks 1 letter, how can combination of letters? ex.: find letters "ac" in array , output them textbox2
string[] alphabet = new string[] { "a", "b", "c"}; (int letter = 0; letter < alphabet.length; letter++) { if (textbox1.text == alphabet[letter]) textbox2.text = alphabet[letter]; }
i guess want check if letters of array entered in textbox:
bool valid = textbox1.text.all(c => alphabet.contains(c.tostring()));
if char[]
write:
bool valid = textbox1.text.all(alphabet.contains);
then use enumerable.except
set difference:
var notvalidletters = textbox1.text.except(alphabet); textbox2.text = "following not valid letters: " + string.join(", ", notvalidletters);
Comments
Post a Comment