<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The Yield Statement in C#</title>
	<atom:link href="http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/</link>
	<description>Software by Design</description>
	<lastBuildDate>Tue, 02 Mar 2010 13:21:48 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Manpreet</title>
		<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/comment-page-1/#comment-3400</link>
		<dc:creator>Manpreet</dc:creator>
		<pubDate>Mon, 16 Mar 2009 23:56:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/#comment-3400</guid>
		<description>good one. Informative.</description>
		<content:encoded><![CDATA[<p>good one. Informative.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dushouke</title>
		<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/comment-page-1/#comment-3225</link>
		<dc:creator>dushouke</dc:creator>
		<pubDate>Sun, 22 Feb 2009 05:56:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/#comment-3225</guid>
		<description>good~~~</description>
		<content:encoded><![CDATA[<p>good~~~</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C# tips &#171; Bobobobo&#8217;s Weblog</title>
		<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/comment-page-1/#comment-3003</link>
		<dc:creator>C# tips &#171; Bobobobo&#8217;s Weblog</dc:creator>
		<pubDate>Sat, 24 Jan 2009 16:05:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/#comment-3003</guid>
		<description>[...] couple of links that explain yield pretty well: The yield statement in C#,  Behind the scenes of the C# yield keyword, Give way to the YIELD [...]</description>
		<content:encoded><![CDATA[<p>[...] couple of links that explain yield pretty well: The yield statement in C#,  Behind the scenes of the C# yield keyword, Give way to the YIELD [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Own MLM Company</title>
		<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/comment-page-1/#comment-2958</link>
		<dc:creator>Own MLM Company</dc:creator>
		<pubDate>Tue, 13 Jan 2009 22:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/#comment-2958</guid>
		<description>Judah,
It would be great if some one would answer to David Brenchley&#039;s quesion on thread safety. I am intersted too.
Jacobson</description>
		<content:encoded><![CDATA[<p>Judah,<br />
It would be great if some one would answer to David Brenchley&#8217;s quesion on thread safety. I am intersted too.<br />
Jacobson</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lars Corneliussen</title>
		<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/comment-page-1/#comment-2103</link>
		<dc:creator>Lars Corneliussen</dc:creator>
		<pubDate>Tue, 10 Jun 2008 21:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/#comment-2103</guid>
		<description>If you&#039;re interested in how the yield keyword actually works, read this:

http://startbigthinksmall.wordpress.com/2008/06/09/behind-the-scenes-of-the-c-yield-keyword/</description>
		<content:encoded><![CDATA[<p>If you&#8217;re interested in how the yield keyword actually works, read this:</p>
<p><a href="http://startbigthinksmall.wordpress.com/2008/06/09/behind-the-scenes-of-the-c-yield-keyword/" rel="nofollow">http://startbigthinksmall.wordpress.com/2008/06/09/behind-the-scenes-of-the-c-yield-keyword/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Brenchley</title>
		<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/comment-page-1/#comment-1158</link>
		<dc:creator>David Brenchley</dc:creator>
		<pubDate>Fri, 24 Aug 2007 14:44:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/#comment-1158</guid>
		<description>Is the yield threadsafe?  What happens when you have 2 threads hitting the same static method?  Is the state maintained for each separate thread?</description>
		<content:encoded><![CDATA[<p>Is the yield threadsafe?  What happens when you have 2 threads hitting the same static method?  Is the state maintained for each separate thread?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Judah</title>
		<link>http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/comment-page-1/#comment-1157</link>
		<dc:creator>Judah</dc:creator>
		<pubDate>Thu, 23 Aug 2007 16:08:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/22/the-yield-statement-in-c/#comment-1157</guid>
		<description>One key point to add is that execution of yield methods are deferred: they aren&#039;t evaluated until you foreach over them. Thus, the following code, even though it looks like an infinite loop, is perfectly fine:

while(true)
{
   yield return 1;
}

It will simply keep yielding 1 until you stop foreach-ing over it.

Another point to consider is that since yield methods are delay-executed, any argument validation won&#039;t get applied until you foreach over it. For example,

IEnumerable GetEvens(IEnumerable input)
{
    if (input == null ) throw new ArgumentNullException();
   ...

   yield return ...;
}

Calling that method like this:
IEnumerable evens = GetEvents(null);

It won&#039;t result in an exception! Not until you foreach over evens.

For this reason, argument validation should be done first, then return the result of another method that does the actual yielding.</description>
		<content:encoded><![CDATA[<p>One key point to add is that execution of yield methods are deferred: they aren&#8217;t evaluated until you foreach over them. Thus, the following code, even though it looks like an infinite loop, is perfectly fine:</p>
<p>while(true)<br />
{<br />
   yield return 1;<br />
}</p>
<p>It will simply keep yielding 1 until you stop foreach-ing over it.</p>
<p>Another point to consider is that since yield methods are delay-executed, any argument validation won&#8217;t get applied until you foreach over it. For example,</p>
<p>IEnumerable GetEvens(IEnumerable input)<br />
{<br />
    if (input == null ) throw new ArgumentNullException();<br />
   &#8230;</p>
<p>   yield return &#8230;;<br />
}</p>
<p>Calling that method like this:<br />
IEnumerable evens = GetEvents(null);</p>
<p>It won&#8217;t result in an exception! Not until you foreach over evens.</p>
<p>For this reason, argument validation should be done first, then return the result of another method that does the actual yielding.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
