Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string RotateRight(this string str, int count)
- {
- if (count >= str.Length)
- {
- count = count - str.Length;
- }
- return str.Substring(str.Length - count, count) + str.Substring(0, str.Length - count);
- }
- public static string RotateLeft(this string str, int count)
- {
- if (count >= str.Length)
- {
- count = count - str.Length;
- }
- return str.Substring(count, str.Length - count) + str.Substring(0, count);
- }
- public static string RotateByLetter(this string str, char letter)
- {
- int count = str.IndexOf(letter);
- if (count >= 4)
- {
- count++;
- }
- return str.RotateRight(count + 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment