<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://aspxwizard.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>.net Wand - All Comments</title><link>http://aspxwizard.net/blogs/wand/default.aspx</link><description>.net used for magic </description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Dynamically Resize an IFrame According to its contents</title><link>http://aspxwizard.net/blogs/wand/archive/2008/11/25/dynamically-resize-an-iframe-according-to-its-contents.aspx#7957</link><pubDate>Tue, 25 Nov 2008 12:54:17 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:7957</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You've been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=7957" width="1" height="1"&gt;</description></item><item><title>re: Windows Fake URL test [hosts file]</title><link>http://aspxwizard.net/blogs/wand/archive/2008/03/09/windows-fake-url-test-hosts-file.aspx#3732</link><pubDate>Sun, 21 Sep 2008 05:02:20 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:3732</guid><dc:creator>Rimon Tadros</dc:creator><description>&lt;p&gt;Good artical Amir,&lt;/p&gt;
&lt;p&gt;Zac, you can connect to SQL server using many protocols, in SQL server 2005 you can use: TCP/IP, named pipes, shared memory, and VIA.&lt;/p&gt;
&lt;p&gt;if you want to connect to SQL server use the hosts file&amp;#39; entry then your SQL server should be TCP/IP enabled&lt;/p&gt;
&lt;p&gt;in SQL server 2005: go to &amp;quot;SQL Server Configuration Manager&amp;quot; and select &amp;quot;Network Configuration&amp;quot; and enable the TCP/IP&lt;/p&gt;
&lt;p&gt;in SQL server 2000: go to “Client Network Utility” and in “SQL Server Client Network Utility” &amp;nbsp;window, click the “General” tab, and enable the TCP/IP&lt;/p&gt;
&lt;p&gt;then from “services” restart SQL server, and connect to the entry in the hosts file, it should work :)&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=3732" width="1" height="1"&gt;</description></item><item><title>Most Used Javascript Date functions</title><link>http://aspxwizard.net/blogs/wand/archive/2008/08/21/most-used-javascript-functions.aspx#1450</link><pubDate>Thu, 21 Aug 2008 19:26:15 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:1450</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You've been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=1450" width="1" height="1"&gt;</description></item><item><title>re: Windows Fake URL test [hosts file]</title><link>http://aspxwizard.net/blogs/wand/archive/2008/03/09/windows-fake-url-test-hosts-file.aspx#877</link><pubDate>Fri, 13 Jun 2008 19:00:52 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:877</guid><dc:creator>Zac Boyles</dc:creator><description>&lt;p&gt;Just searching around for an example to get hosts file edits to work with sql's integrated security. If I reference the &amp;quot;Fake URL&amp;quot; in the connection string and test it, an error message displays stating that user &amp;quot;&amp;quot; cannot be validated. Just wondering why it doesn't carry it over.&lt;/p&gt;
&lt;p&gt;If you know, please email zac.boyles@sunfestcaribe.com&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Zac&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=877" width="1" height="1"&gt;</description></item><item><title>re: Have u ever needed to extend a string? [Extension Methods]</title><link>http://aspxwizard.net/blogs/wand/archive/2007/12/27/have-u-ever-needed-to-extend-a-string-extension-methods.aspx#206</link><pubDate>Mon, 17 Mar 2008 15:34:40 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:206</guid><dc:creator>Amr ElGarhy</dc:creator><description>&lt;p&gt;Found a good post about the same idea as yours, with some more sample:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://www.c-sharpcorner.com/UploadFile/mgold/ExtendingStringClass03162008132109PM/ExtendingStringClass.aspx"&gt;www.c-sharpcorner.com/.../ExtendingStringClass.aspx&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=206" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#136</link><pubDate>Sat, 08 Mar 2008 14:32:46 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:136</guid><dc:creator>amir.magdy</dc:creator><description>&lt;p&gt;yep ur right it'll break once it gets to the end of array &lt;/p&gt;
&lt;p&gt;i was trying to make my sample as easy as possible&lt;/p&gt;
&lt;p&gt;thank you &lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=136" width="1" height="1"&gt;</description></item><item><title>Egypt: Heroes Happen Here (AKA, Microsoft 2008 Launch Event in Cairo)</title><link>http://aspxwizard.net/blogs/wand/archive/2008/03/06/2008-launch-event-in-egypt-heroes-happen-here.aspx#134</link><pubDate>Thu, 06 Mar 2008 16:57:09 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:134</guid><dc:creator>Guru Stop</dc:creator><description>&lt;p&gt;It's very nice to know that the launch event is not merged with EDC 2008 , but comes before it. The 2008&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=134" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#129</link><pubDate>Wed, 05 Mar 2008 17:24:02 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:129</guid><dc:creator>Jon Hanna</dc:creator><description>&lt;p&gt;Okay, so let's start by fixing the bug. It should be something like :&lt;/p&gt;
&lt;p&gt;do&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;yield return numbers[_index];&lt;/p&gt;
&lt;p&gt;}while(++_index != numbers.Length);&lt;/p&gt;
&lt;p&gt;so that we don't get an index error after _index exceeds the bounds.&lt;/p&gt;
&lt;p&gt;You say &amp;quot;note that this new Interface IEnumerable&amp;lt;T&amp;gt; needs both methods to be implemented&amp;quot;. This is true, but because IEnumerator&amp;lt;T&amp;gt; extends IEnumerator you can do so just by using:&lt;/p&gt;
&lt;p&gt;public class enu : IEnumerable&amp;lt;int&amp;gt;&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int _index=0;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int[] numbers = { 1, 2, 3, 4, 5 };&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;IEnumerator IEnumerable.GetEnumerator()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return GetEnumerator();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public IEnumerator&amp;lt;int&amp;gt; GetEnumerator()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;do&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yield return numbers[_index];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}while(++_index != numbers.Length);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;This class has two advantages over your example. Firstly the implementation of the non-generic form simply re-uses the generic form, with all the advantages re-use gives us.&lt;/p&gt;
&lt;p&gt;Secondly, because it is the generic (and more narrowly typed) form that is defined publicly and the non-generic that is defined by refering to the interface, this is now more flexible for someone who explicitly calls GetEnumerator(). Before this would have returned an IEnumerator and only usable as this, now it returns an IEnumerator&amp;lt;int&amp;gt; and usable as that or by implicitly casting to IEnumerator - the best of both worlds.&lt;/p&gt;
&lt;p&gt;Even better though can be the following, since the only thing this class does is implement IEnumerator&amp;lt;int&amp;gt; for the range in question we can make use of the fact that iterator blocks can not only return IEnumerator or IEnumerator&amp;lt;T&amp;gt; but also can return IEnumerable&amp;lt;T&amp;gt; or IEnumerable. Hence for this example we could use a method like:&lt;/p&gt;
&lt;p&gt;public IEnumerable&amp;lt;int&amp;gt; enu()&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int index=0;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;int[] numbers = { 1, 2, 3, 4, 5 };&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;do&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yield return numbers[index];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}while(++index != numbers.Length);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Then instead of using foreach(int x in new enu()) we use foreach(int x in enu()). The lack of a full class definition (in the code, of course the runtime creates a new class for us) can nicely reduce the mental complexity of the code. It can also be very useful since this method would have full access to private members of whatever class it was defined in (if that isn't appropriate it can be defined as static).&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=129" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#128</link><pubDate>Wed, 05 Mar 2008 16:33:15 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:128</guid><dc:creator>Antão</dc:creator><description>&lt;p&gt;Did you test this? It doesn't iterate. The output is just 1...&lt;/p&gt;
&lt;p&gt;It should be something like this:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;public class enu : IEnumerable&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int[] numbers = { 1, 2, 3, 4, 5 };&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public IEnumerator GetEnumerator()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;foreach(int i in numbers)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;yield return i;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;}&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=128" width="1" height="1"&gt;</description></item><item><title>W&amp;ouml;chentliche Rundablage: ASP.NET MVC, ASP.NET, Windows Live, Silverlight 2, LINQ, C# 3.0, CardSpace&amp;#8230; | Code-Inside Blog</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#127</link><pubDate>Mon, 03 Mar 2008 19:21:44 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:127</guid><dc:creator>Wöchentliche Rundablage: ASP.NET MVC, ASP.NET, Windows Live, Silverlight 2, LINQ, C# 3.0, CardSpace… | Code-Inside Blog</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;W&amp;amp;ouml;chentliche Rundablage: ASP.NET MVC, ASP.NET, Windows Live, Silverlight 2, LINQ, C# 3.0, CardSpace&amp;amp;#8230; | Code-Inside Blog&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=127" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#126</link><pubDate>Mon, 03 Mar 2008 16:35:39 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:126</guid><dc:creator>Jon Skeet</dc:creator><description>&lt;p&gt;I've recently written an article about iterator blocks which I would personally find clearer than this explanation. I know, I'm biased - but it gives people alternatives :)&lt;/p&gt;
&lt;p&gt;I've provided the article link as the URL for this comment.&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=126" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#125</link><pubDate>Mon, 03 Mar 2008 12:34:10 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:125</guid><dc:creator>greg1</dc:creator><description>&lt;p&gt;kicked..&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=125" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#124</link><pubDate>Mon, 03 Mar 2008 09:14:02 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:124</guid><dc:creator>Jakub Sturc</dc:creator><description>&lt;p&gt;hi, &lt;/p&gt;
&lt;p&gt;what is the output of following line (considering the third implementation)?&lt;/p&gt;
&lt;p&gt;foreach (var e in new enu()) Console.WriteLine(e);&lt;/p&gt;
&lt;p&gt;just 1. i don't think it was the intent.&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=124" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#123</link><pubDate>Mon, 03 Mar 2008 07:27:45 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:123</guid><dc:creator>Vijay Santhanam</dc:creator><description>&lt;p&gt;Good example.&lt;/p&gt;
&lt;p&gt;Maybe the hour long explanation was an exaggeration and hard for said listener to understand without seeing some code.&lt;/p&gt;
&lt;p&gt;You should also describe what the compiler does with yield, cos that's what makes it strange and cool in my opinion. In one line in you're in a foreach loop, then the next Step over will put u inside another method. So strange.&lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=123" width="1" height="1"&gt;</description></item><item><title>re: Yield in c#</title><link>http://aspxwizard.net/blogs/wand/archive/2008/02/25/yield-in-c.aspx#122</link><pubDate>Mon, 03 Mar 2008 06:41:02 GMT</pubDate><guid isPermaLink="false">318922e2-3002-4869-8654-4cebdb510d6f:122</guid><dc:creator>Michael Sync</dc:creator><description>&lt;p&gt;&amp;gt;&amp;gt;i've been trying to explain the keyword yield to a friend of mine for more than an hour and he did not get it. but finally when i typed in this example he finally did&lt;/p&gt;
&lt;p&gt;Your friend said he got it after listening your explanation for 1 hour? &amp;nbsp;maybe, he is tried of listening.. :) cuz I'm not sure why he suddenly understand about &amp;quot;yield&amp;quot; when he saw those sample codes. &lt;/p&gt;
&lt;img src="http://aspxwizard.net/aggbug.aspx?PostID=122" width="1" height="1"&gt;</description></item></channel></rss>