/// <summary> /// 获取两个数组的所有结合的结果值 /// </summary> /// <param name="args"></param> static void Main(string[] args) { var strs1 = new string[] { "w", "q", "b", "s", "g" }; var strs2 = new string[] { "1", "2", "3" }; Console.WriteLine(NewString(strs1, strs2)); } public static string NewString(string[] strs1, string[] strs2) { Stopwatch sw = new Stopwatch(); sw.Start(); var len1 = strs1.Length; var runStr = ""; for (int i = 0; i < len1-2; i++) { for (int j = i+1; j < len1-1; j++) { for (int k = j+1; k < len1; k++) { runStr += strs1[i] + strs2[0] + strs1[j] + strs2[1] + strs1[k] + strs2[2] + " "; } } } sw.Stop(); Console.WriteLine("运行总时间:"+sw.ElapsedTicks +"毫秒"); return runStr; }
效果展示: