c# - New dictionary using LINQ to dictionary -


i have dictionary<position, list<gameobject>> , want create new dictionary dictionary<position, list<person>> collect positions including @ least 1 person in list<gameobject>.

i tried:

dictionary<position, list<person>> persons =     positions.todictionary(         => i.key,          => i.value.where(obj => obj person)) 

positions first dictionary.

but doesn't work because position null , not type of person because don't convert it. anyway, have ideas?

var people = positions.select(x => new { x.key, values = x.value.oftype<person>().tolist() })                       .where(x => x.values.any())                       .todictionary(x => x.key, x => x.values) 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -