i have the following
string[] statelookup = ConfigurationManager.AppSettings["WstmStateLookUp"].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
with these values
"AL, AR, CT, MD, DE, FL, GA, IA, IL, IN, KY, LA, MA, ME, MI, MN, MO, MS, NC, NH, NJ, NY, OH, PA, RI, SC, TN, VA, VT, WI, WV"
I need to see if any line from a file contains one of the above values. A sample line is this
<FIPS>20170<STATE>AL<WFO>AJK
When I use the following, I only get results for whatever is the first item in the statelookup (in this case, AL).
statelookup.Any(a => currentLine.Contains("<STATE>"+a))
i can move items around (say have OH first and ill get the OH result) but I cant seem to be able to return all the lines form the file that contain ANY of the statelookup values.
I have to use
"<STATE"+a
because AL, AK, and RI can appear in other lines of the file. this way I only look for this spcific instance.
What am i missing?
lines.Where(currentLine -> statelookup.Any(a => currentLine.Contains("<STATE>"+a))).ToList()should work.AL? This line:<FIPS>20170<STATE>AL<WFO>AJKonly contains<STATE>ALso why should it return any other state?