c# - LINQ - GROUP BY on object to create string -


so have object called version

it contains list of states, , list of dates

i want first:

  1. group states, , create string of states (comma separated)
  2. group dates, , create string of dates (comma separated)

here have tried:

date = version.states.groupby(v => v.date).select(vh => vh.tostring()).tostring(), state = version.states.groupby(s => s.state).select(st => st.tostring()).tostring() 

can me out here?

try this:

    var states = version.states.aggregate(string.empty, (c, state) => c + state.tostring() + ",").trimend(new []{','});     var dates = version.dates.aggregate(string.empty, (c, date) => c + date.tostring() + ",").trimend(new []{','}); 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -