5
我有這樣的結構:的LINQ的GroupBy切換尺寸
var data1 = new Dictionary<int, List<string>>
{
{ 1, new List<string> { "A", "B", "C" } },
{ 2, new List<string> { "B", "C" } }
};
,我需要把它轉換成這種結構:
var data2 = new Dictionary<string, List<int>>
{
{ "A", new List<int> { 1 } },
{ "B", new List<int> { 1, 2 } },
{ "C", new List<int> { 1, 2 } }
};
我如何使用LINQ到這樣做呢?我使用GroupBy嗎?
感謝