我在根据列表中元组的Item1将元组列表分隔给不同的组时遇到问题(每个组基本上应该具有相同的Item1)
代码:
static List<Tuple<string, string, string>> myList = new List<Tuple<string, string, string>>();
myList.Add(new Tuple<string, string, string>("GroupA", "", ""));
myList.Add(new Tuple<string, string, string>("GroupA", "", ""));
myList.Add(new Tuple<string, string, string>("GroupB", "", ""));
myList.Add(new Tuple<string, string, string>("GroupB", "", ""));
myList.Add(new Tuple<string, string, string>("GroupC", "", ""));
我想做的是将这些添加的项目分组,(基本上是另外3个元组列表,A组,B组,C组)。
答案 0 :(得分:1)
您可以按Item1
var lists = myList.GroupBy(c => c.Item1);