Advertisement
kyrathasoft

IsAlphabetical

May 20th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1.     public static bool IsAlphabetical(string p)
  2.     {
  3.         /*returns true if every character in the passed
  4.         argument is either a lower- or upper-case letter
  5.         of the English alphabet; false otherwise */
  6.        
  7.         bool result = true;
  8.        
  9.         byte[] word = StringToByteArray(p);
  10.         foreach(byte b in word)
  11.         {
  12.             if(b < 65)
  13.             {
  14.                 return false;
  15.             }else{
  16.                 if (b > 122){
  17.                     return false;
  18.                 }else{
  19.                     if((b > 90) && (b < 97)){
  20.                         return false;
  21.                     }
  22.                 }
  23.             }
  24.            
  25.         }
  26.        
  27.         return result;
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement