Parent has list of Children. I only have access to the list of children. I need to get list of unique parents from the List of Children. Is there a better/faster/more efficient way of doing it than this?var temp = new HashSet<Parent>(                        (from child in program.Children                        select child.Parent).ToList());
Get list of unique parents from childrens list
c#;linq
Your use of var is good, but names like temp is meaningless. It's a temp what exactly? A more descriptive name is in order here. The call to ToList appears to be redundant. Hashset's constructor takes an IEnumerable<T> and Linq queries that return collections already return one.I would also break the query away from the ctor for readability purposes. var parents = from child in program.Children                 select child.Parent;var distinctParents = new HashSet<Parent>(allParents);However, it's all kind of moot if you use the method syntax snippet that @RobH posted. var parents = program.Children.Select(c => c.Parent).Distinct(); 