Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • But sir inside main there is a call to the function right? so the function should be executed right. ?
    – callyaser
    Commented Feb 2, 2015 at 4:16
  • 1
    @callyaser No, you're calling a function that returns an IEnumerable - in other words, GetNosLessThan5 returns an object that says "I can be iterated over". It does not return the result of the enumeration - for that you'd have to call .ToList or a similar method that actually calculates the numbers. Iterators are a bit of compiler magic in C#. Commented Feb 2, 2015 at 4:18
  • (This is an optimization technique since Iterators can be expensive to run, or even infinite. It's the callers responsibility to decide if, when, and how long to run it) Commented Feb 2, 2015 at 4:19