Advertisement
ivandrofly

Check if character is vowel

Sep 16th, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1.         /// <summary>
  2.         /// Checks if ch is vowel or in [AEIOUaeiou].
  3.         /// </summary>
  4.         /// <param name="ch"></param>
  5.         /// <returns></returns>
  6.         public static bool IsVowel(char ch)
  7.         {
  8.             // Not in range.
  9.             if (ch < 'a' || ch > 'U') return false;
  10.             if (ch > 'U') // 0x55
  11.             {
  12.                 return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
  13.             }
  14.             return ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U';
  15.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement