J'ai un tableau String un peu comme ceci:
// 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"},
};
Ensuite, je remplis un List<Button>
avec mon type de bouton nommé mainButtons
Voici comment je demande le regroupement pour Category
:
var categories = from b in mainButtons
group b by b.category into g
select new { Category = g.Key, Buttons = g };
Comment puis-je sélectionner le premier élément de chaque groupe dans ma liste principale ? (sans itérer chacun et ajouter à une autre liste ?)