Store the generated permutations into the resultant arraylist
List < String > Res = new List < String > ( ) ; foreach ( String val in prevResult ) { for ( int i = 0 ; i <= val . Length ; i ++ ) { Res . Add ( val . Substring ( 0 , i ) + ch + val . Substring ( i ) ) ; } }