Ad
Code
Diff
  • public static class Kata
    {
        public static int SameCase(char a, char b)
        {
            if (!IsLetter(a) || !IsLetter(b))
            {
                return -1;
            }
    
            return IsUpper(a) == IsUpper(b) ? 1 : 0;
        }
    
        private static bool IsLetter(char c)
        {
            return (uint)(c - 'A') <= ('Z' - 'A') || (uint)(c - 'a') <= ('z' - 'a');
        }
    
        private static bool IsUpper(char c)
        {
            return (uint)(c - 'A') <= ('Z' - 'A');
        }
    }
    
    • public static class Kata
    • public static class Kata
    • {
    • public static int SameCase(char a, char b) =>
    • !char.IsLetter(a) || !char.IsLetter(b)
    • ? -1
    • : char.IsUpper(a) == char.IsUpper(b)
    • ? 1 : 0;
    • }
    • public static int SameCase(char a, char b)
    • {
    • if (!IsLetter(a) || !IsLetter(b))
    • {
    • return -1;
    • }
    • return IsUpper(a) == IsUpper(b) ? 1 : 0;
    • }
    • private static bool IsLetter(char c)
    • {
    • return (uint)(c - 'A') <= ('Z' - 'A') || (uint)(c - 'a') <= ('z' - 'a');
    • }
    • private static bool IsUpper(char c)
    • {
    • return (uint)(c - 'A') <= ('Z' - 'A');
    • }
    • }