質問

私は、2つの配列を持っています:

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

string[] combination = { "C#", "Java", null, "C++", null }; 

私のようなすべての可能な組み合わせを戻したいです

{ {"A","C#"} , {"A","Java"} , {"A","C++"},{"B","C#"},............ }

nullは無視する必要があります。

役に立ちましたか?

解決

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 }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top