How to check if string contains a string in string array
Posted
by
Abu Hamzah
on Stack Overflow
See other posts from Stack Overflow
or by Abu Hamzah
Published on 2012-09-27T21:30:48Z
Indexed on
2012/09/27
21:37 UTC
Read the original article
Hit count: 187
edit: the order might change as you can see in the below example, both string have same name but different order....
How would you go after checking to see if the both string array match?
the below code returns true but in a reality its should return false since I have extra string array in the _check
what i am trying to achieve is to check to see if both string array have same number of strings.
string _exists = "Adults,Men,Women,Boys";
string _check = "Men,Women,Boys,Adults,fail";
if (_exists.All(s => _check.Contains(s))) //tried Equal
{
return true;
}
else
{
return false;
}
© Stack Overflow or respective owner