its me. i got the following code:
foreach (var str in usedCSS) {
if (CSS.Any(c => c.IndexOf(str)>0))
Response.Write(str + "<br />");
else
Response.Write("Could not find: " + str + "<br />");
}
usedCSS = List<string>
CSS = List<string>
but, i need it the other way around…
i want the var str in usedCSS to be var str in CSS
usedCSS contains strings of only the css names e.g: .header
CSS contains string of the actual css e.g: .header {font-size:14px;}
basicly, what i need is to print out the actuall CSS that is used.
The code i currently have does the exact opposite, it returns only the css names,
not the actuall css.
If I understand what it is you’re trying to do correctly, you could do this.
FirstOrDefault()finds the first occurrence of a predicate match and returns it, ornull(default for typestring) if not found. Then all we need is theStartsWith()string method to match each item in CSS prefix-wise with thestrin question.p.s. The above works if you only expect one or no matches, if you can have multiple matches, and want them all: