public void CycleShift(ref String strarr, int rotdist) { int n = strarr.Length; for (int i = 0; i < this.GetCommonDivisor(n, rotdist); i++) { Char t = strarr[i]; int j = i; while (true) { int k = j + rotdist; if (k >= n) k -= n; if (k == i) break; //Делаем strarr[j] = strarr[k]; this.ReplaceCharInString(ref strarr, j, strarr[k]); j = k; } //Делаем strarr[j] = t; this.ReplaceCharInString(ref strarr, j, t); } }