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 - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -