创建2个字符数组的所有单词变体

Nea*_*ale 2 c# arrays string generics collections

我有两个caracter字符串ex集合:

List<string> one = new List<string>;
one.Add("a");
one.Add("b");
one.Add("c");

List<string> two = new List<string>;
two.Add("x");
two.Add("y");
two.Add("z");
Run Code Online (Sandbox Code Playgroud)

我想要做的是创建一个列表,列出可以从中创建的所有单词变体.但我只想创造4个字符的单词!所以例如我想要的话

axax (from one[1],two[1],one[1],two[1])
ayax (from one[1],two[2],one[1],two[1])
azax (from one[1],two[3],one[1],two[1])
Run Code Online (Sandbox Code Playgroud)

最终到了

czcz (from one[3],two[3],one[3],two[3])
Run Code Online (Sandbox Code Playgroud)

关于以最快和最好的方式生成这个的任何建议

Dan*_*att 5

我怀疑这个解决方案会赢得任何速度奖,但它应该相当快:

var one = new [] { "a", "b", "c" };
var two = new [] { "x", "y", "z" };

var ot = from o in one from t in two select o + t;
var r = from f in ot from s in ot select f + s;
var list = r.ToList();
Run Code Online (Sandbox Code Playgroud)