C# List Group By with where -


hi i'm trying group c# list. how looks.

name    user     fred    true     fred    false    fred    true     joe     true     joe     true     max     false    max     true     

result:

enter image description here

this how wanted after group by, how can in c#?

you can group name , use enumerable.count predicate here:

var result = list    .groupby(x => x.name)    .select(g => new     {         name = g.key,         true = g.count(x => x.user == true),        false = g.count(x => x.user == false)    }); 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -