Skip to main content

Check that the given string is in a list of potential matches.

        /// <summary>
        /// Check that the given string is in a list of potential matches.
        /// </summary>
        /// <returns><c>true</c>, if any was equalsed, <c>false</c> otherwise.</returns>
        /// <param name="str">String.</param>
        /// <param name="args">Arguments.</param>
        /// <remarks>Inspired by StackOverflow answer http://stackoverflow.com/a/20644611/23199</remarks>
        /// <example>
        /// string custName = "foo";
        /// bool isMatch = (custName.EqualsAny("bar", "baz", "FOO"));
        /// </example>
        public static bool EqualsAny(this string str, params string[] args)
        {
            return args.Any(x => StringComparer.OrdinalIgnoreCase.Equals(x, str));
        }