public void CycleShiftByBlocks(ref String strarr, int rotdist) { int n = strarr.Length; if (rotdist == 0 || rotdist == n) return; int i, j, p; i = p = rotdist; j = n - p; while (i != j) { if (i > j) { this.StrSwap(ref strarr, p - i, p, j); i -= j; } else { this.StrSwap(ref strarr, p - i, p + j - i, i); j -= i; } } this.StrSwap(ref strarr, p - i, p, i); }