我有輸入就像“dir1/dir2/Demo.txt”結合我想要的輸出“dir1/dir2/Demo.txt”“dir1/dir2/DEMO.txt”"dir1/DIR2/Demo.txt"“dir1/DIR2/DEMO.txt”"DIR1/dir2/Demo.txt""DIR1/dir2/DEMO.txt"“DIR1/DIR2/Demo.txt”"DIR1/DIR2/DEMO.txt"據我所知,我編寫的代碼如下 var s = "dir1/dir2/Demo.txt"; List<string> listPermutations = new List<string>(); string[] array = s.Split('/'); int iterations = (1 << array.Length) -1; for( int i = 0; i <= iterations; i++ ) { for( int j = 0; j < array.Length; j++ ) array[j] = (i & (1<<j)) != 0 ? array[j].ToUpper() : array[j]; listPermutations.Add(string.Join("/",array )); }
- 1 回答
- 0 關注
- 163 瀏覽
添加回答
舉報
0/150
提交
取消