Last active
March 14, 2023 19:41
-
-
Save icodeintx/2963be7f166ffc784683999c5e225a47 to your computer and use it in GitHub Desktop.
String List Comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A nice way to find out if a string contains any value in a string list | |
using System.Linq; | |
public static bool ContainsAny(string s, List<string> substrings) | |
{ | |
if (string.IsNullOrEmpty(s) || substrings == null) | |
return false; | |
return substrings.Any(substring => s.Contains(substring, StringComparison.CurrentCultureIgnoreCase)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment