Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从两个列表中计算所有可能的项目对?_C#_.net_Linq_Combinations - Fatal编程技术网

C# 从两个列表中计算所有可能的项目对?

C# 从两个列表中计算所有可能的项目对?,c#,.net,linq,combinations,C#,.net,Linq,Combinations,我有两个阵列: string[] Group = { "A", null, "B", null, "C", null }; string[] combination = { "C#", "Java", null, "C++", null }; 我希望返回所有可能的组合,如: { {"A","C#"} , {"A","Java"} , {"A","C++"},{"B","C#"},............ } 应忽略空值 Group.Where(x => x != null)

我有两个阵列:

string[] Group = { "A", null, "B", null, "C", null };

string[] combination = { "C#", "Java", null, "C++", null }; 
我希望返回所有可能的组合,如:

{ {"A","C#"} , {"A","Java"} , {"A","C++"},{"B","C#"},............ }
应忽略空值

Group.Where(x => x != null)
     .SelectMany(g => combination.Where(c => c != null)
                                 .Select(c => new {Group = g, Combination = c})
     );
或者:

from g in Group where g != null
from c in combination where c != null
select new { Group = g, Combination = c }

谢谢Mehrdad的及时回复。你知道如何有效地进行排列而不仅仅是组合吗?(意思是{“A”、“C”}和{“C”},“A”}将被视为两个独立的项目)?