I have a String array kinda like this:
// icon, category, tool
String[,] subButtonData = new String[,]
{
{"graphics/gui/brushsizeplus_icon", "Draw", "DrawBrushPlus"},
{"graphics/gui/brushsizeminus_icon", "Draw", "DrawBrushMinus"},
{"graphics/gui/freedraw_icon", "Draw", "DrawFree"},
{"graphics/gui/linedraw_icon", "Draw", "DrawLine"},
{"graphics/gui/rectangledraw_icon", "Draw", "DrawRectangle"},
{"graphics/gui/ellipsedraw_icon", "Draw", "DrawEllipse"},
{"graphics/gui/brushsizeplus_icon", "Brusher", "BrusherBrushPlus"},
{"graphics/gui/brushsizeminus_icon", "Brusher", "BrusherBrushMinus"},
{"graphics/gui/brushsizeplus_icon", "Text", "TextBrushPlus"},
{"graphics/gui/brushsizeminus_icon", "Text", "TextBrushMinus"},
};
Then I populate a List<Button>
with my Button Type named mainButtons
This is how I query for grouping for Category
:
var categories = from b in mainButtons
group b by b.category into g
select new { Category = g.Key, Buttons = g };
How can I select the first item of each group in my main List? (without iterating each and adding to another List?)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…