Answer by Bolpat for In C#, why can't an anonymous method contain a yield...
Maybe its just a syntax limitation. In Visual Basic .NET, which is very similar to C#, it is perfectly possible while awkward to writeSub Main() Console.Write("x: ") Dim x = CInt(Console.ReadLine())...
View ArticleAnswer by Sly1024 for In C#, why can't an anonymous method contain a yield...
I would do this:IList<T> list = GetList<T>();var fun = expression.Compile();return list.Where(item => fun.Invoke(item)).ToList();Of course you need the System.Core.dll referenced from...
View ArticleAnswer by Thomas Levesque for In C#, why can't an anonymous method contain a...
Eric Lippert recently wrote a series of blog posts about why yield is not allowed in some cases.Part 1Part 2Part 3Part 4Part 5Part 6EDIT2:Part 7(this one was posted later and specifically addresses...
View ArticleAnswer by ShuggyCoUk for In C#, why can't an anonymous method contain a yield...
Eric Lippert has written an excellent series of articles on the limitations (and design decisions influencing those choices) on iterator blocksIn particular iterator blocks are implemented by some...
View ArticleAnswer by Lasse V. Karlsen for In C#, why can't an anonymous method contain a...
Unfortunately I don't know why they didn't allow this, since of course it's entirely possible to do envision how this would work.However, anonymous methods are already a piece of "compiler magic" in...
View ArticleIn C#, why can't an anonymous method contain a yield statement?
I thought it would be nice to do something like this (with the lambda doing a yield return):public IList<T> Find<T>(Expression<Func<T, bool>> expression) where T : class, new(){...
View Article