Guest User

Untitled

a guest
Dec 21st, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1.        public static string RotateRight(this string str, int count)
  2.         {
  3.             if (count >= str.Length)
  4.             {
  5.                 count = count - str.Length;
  6.             }
  7.  
  8.             return str.Substring(str.Length - count, count) + str.Substring(0, str.Length - count);
  9.         }
  10.  
  11.         public static string RotateLeft(this string str, int count)
  12.         {
  13.             if (count >= str.Length)
  14.             {
  15.                 count = count - str.Length;
  16.             }
  17.  
  18.             return str.Substring(count, str.Length - count) + str.Substring(0, count);
  19.         }
  20.  
  21.         public static string RotateByLetter(this string str, char letter)
  22.         {
  23.             int count = str.IndexOf(letter);
  24.  
  25.             if (count >= 4)
  26.             {
  27.                 count++;
  28.             }
  29.  
  30.             return str.RotateRight(count + 1);
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment