Does c# have anything comparable to Python's list comprehensions
I want to generate a list in C#. I am missing python's list comprehensions. Is there a c# way to create collections on the fly like list comprehensions or generator statements do in python?
If you are using C# 3.0 (VS2008) then LINQ to Objects can do very similar things:
List<Foo> fooList = new List<Foo>(); IEnumerable<Foo> extract = from foo in fooList where foo.Bar > 10 select Foo.Name.ToUpper();