How can I create an empty collection from an anonymous collection most elegantly in C#?
- by NetMage
If I have an anonymous type created by LINQ
var ans = from r in someList where someCondition(r) select new { r.a, r.b };
What is the best way to create an empty matching collection so I can move elements to the new collection:
var newans = ?
foreach (r in ans) { if (complicated(r) newans.Add(r); }
Is there some way to use Enumerable.Empty<()?