Reputation: 31
I have a line of code that I don't understand what it means, and I don't really know what I have to search on google to find some information about it:
private static string[] errors = new string[6] {"1","2","3","4","5","6"};
string str = httpRequest.Get(s + "'").ToString(); // s = url
if (!(errors).Any<string>(new Func<string, bool>(str.Contains)))
return;
I know this might be a bad question or stupid question but I do want to understand what it does first before I continue with other stuff.
Upvotes: 2
Views: 94
Reputation: 186678
It's not a bad question but code style:
if (!(errors).Any<string>(new Func<string, bool>(str.Contains)))
return;
can be rewritten into readable chunk as
if (!errors.Any(item => str.Contains(item)))
return;
which means "if errors
collection doesn't have (!
) Any
item which Contains
in str
then return
."
Upvotes: 7
Reputation: 460108
Can be simplified: if (!errors.Any(str.Contains)) return;
.
It checks if any of the error-digits are contained in the string str
as substring.
Upvotes: 3