using System.Collections.Generic; using System.Linq; public class Kata { /// <summary> /// Checks if two char arrays contain at least one common item. /// </summary> /// <param name="a">First char array</param> /// <param name="b">Second char array</param> /// <returns>True if the arrays have at least one common item, false otherwise</returns> public static bool ContainsCommonItem(char[] firstCharArray, char[] secondCharArray) { return (firstCharArray == null || secondCharArray == null) ? false : firstCharArray.Intersect(secondCharArray).Any(); } }
- using System.Collections.Generic;
- using System.Linq;
- public class Kata
- {
- /// <summary>
- /// Checks if two char arrays contain at least one common item.
- /// </summary>
- /// <param name="a">First char array</param>
- /// <param name="b">Second char array</param>
- /// <returns>True if the arrays have at least one common item, false otherwise</returns>
public static bool ContainsCommonItem(char[] a, char[] b)- public static bool ContainsCommonItem(char[] firstCharArray, char[] secondCharArray)
- {
// If either input array is null, return falseif (a == null || b == null) return false;return a.Intersect(b).Any();- return (firstCharArray == null || secondCharArray == null) ? false : firstCharArray.Intersect(secondCharArray).Any();
- }
- }