Quantcast
Channel: In C#, why can't an anonymous method contain a yield statement? - Stack Overflow
Browsing latest articles
Browse All 6 View Live

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 Article



Answer 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 Article

Answer 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 Article

Answer 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 Article

Answer 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 Article


In 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
Browsing latest articles
Browse All 6 View Live




Latest Images