c# - splitting string property and linking with other property -
i have list of objects 2 properties. 1 of properties string, , other string containing comma seperated list. want have split list of parts it's associated other property.
i have...
objecta { string propertyx string propertyy e.g. "part1,part2,part3" } list<objecta> objectas
and objectas want collection containing...
{propertyx1, propertyy[0]1 eg. "part1"}, {propertyx1, propertyy[1]1}, {propertyx2, propertyy[0]2}
etc..
you use class objecta
store both properties , selectmany
flatten them:
list<objecta> flattenedlist = objectas .selectmany(obj => obj.propertyy.split(',') .select(propy => new objecta { propertyx = obj.propertyx , propertyy = propy })).tolist();
but store without comma in first place ;-)
Comments
Post a Comment