Complete if statement with strings and array of strings
Posted
by RandomBen
on Stack Overflow
See other posts from Stack Overflow
or by RandomBen
Published on 2010-04-05T17:16:33Z
Indexed on
2010/04/05
17:23 UTC
Read the original article
Hit count: 658
I have a page that has 3 variables. They look like this:
String[] Headers = new String[] { "Max Width", "Max Length", "Max Height" };
String currentHeader = (String)HttpContext.Current.Request.QueryString["ItemHas"] ?? "";
String checkString = (String)HttpContext.Current.Request.QueryString["ItemIn"] ?? "";
The checkString is a list of Headers delimited by a "|".
What is the easiest way to check if my currentHeader
is in my Headers array and in my checkString String? I can do it but not in less than 20 lines of code. That seems like a less than optimal solution.
© Stack Overflow or respective owner