C # finds all permutation combinations of strings
1. Remove First char//2. Find permutations of the rest of chars//3. Attach the first char to each of those permutations.//3.1 for each permutation, move firstchar in all indexes to Pro Duce even more permutations.//4. Return list of possible permutations. Public string[] Findpermutations (string word) {if (Word. Length = = 2) {char[] _c = Word. ToCharArray (); string s = new string (new char[] {_c[1], _c[0]}); return new string[] {word, s}; } List
_result = new List
(); string[] _subsetpermutations = findpermutations (Word. Substring (1)); Char _firstchar = word[0]; foreach (string s in _subsetpermutations) {string _temp = _firstchar.tostring () + s; _result. ADD (_temp); char[] _chars = _temp. ToCharArray (); for (int i = 0; i < _temp. Length-1; i++) {char t = _chars[i]; _chars[i] = _chars[i + 1]; _chars[i + 1] = t; String s2 = new string (_chars); _result. ADD (S2); }} return _result. ToArray (); }