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) { // If either input array is null, return false if (a == null || b == null) return false; return a.Intersect(b).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)
- {
- // If either input array is null, return false
- if (a == null || b == null) return false;
foreach (char ch in a){if (b.Contains(ch)) return true;}return false;- return a.Intersect(b).Any();
- }
- }