I have a linq query
var x = (from t in types select t).GroupBy(g =>g.Type)
which groups objects by their type, as a result I want to have single new object containing all of the grouped objects and their count. Something like this:
type1, 30
type2, 43
type3, 72
to be more clear: grouping results should be in one object not an object per item type
Read : 101 LINQ Samples in that LINQ – Grouping Operators from Microsoft MSDN site
For a single object, make use of
StringBuilderand append it, or convert this in the form of dictionary: