Generate all rotations of a given string | A simple C # program to generate all rotations of a given string ; Print all the rotated string . ; Generate all rotations one by one and print ; Current index in str ; Current index in temp ; Copying the second part from the point of rotation . ; Copying the first part from the point of rotation . ; Driver Code
using System ; using System . Text ; class GFG { public static void printRotatedString ( string str ) { int len = str . Length ; StringBuilder sb ; for ( int i = 0 ; i < len ; i ++ ) { sb = new StringBuilder ( ) ; int j = i ; int k = 0 ; for ( int k2 = j ; k2 < str . Length ; k2 ++ ) { sb . Insert ( k , str [ j ] ) ; k ++ ; j ++ ; } j = 0 ; while ( j < i ) { sb . Insert ( k , str [ j ] ) ; j ++ ; k ++ ; } Console . WriteLine ( sb ) ; } } public static void Main ( string [ ] args ) { string str = " geeks " ; printRotatedString ( str ) ; } }