I almost don't use "yield" operator (I don't hate it :)). I prefer to use LINQ if it is possible. Anyways, I looked for some post (you can find link below) 10 minutes ago, read it and some idea visited my brain :)
rewrite-this-foreach-yield-to-a-linq-yield
Idea: Probably, it is not very good that I don't use "yield". Probably, it has better performance than LINQ or some other advantage.
Therefore I have next question, what code is more "correct" (yield or LINQ) in example above (in common case)?
P.S. I am interesting for cases when we have possibility to use LINQ instead of "yield".
I think it's clearer to use LINQ in that case, personally. It's operating at a higher level than "call this method, yield this result" - it describes the overall results.
Iterator blocks are very useful for implementing LINQ though - either the existing operators, or adding your own. It's worth knowing about them, but I wouldn't worry about the fact that you're not using them much - that's not a sign of poor code or anything like that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With