<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/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>The Visual Basic Team : VB2010</title><link>http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx</link><description>Tags: VB2010</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Spot the Bug! – The Key to using Anonymous Types (Jonathan Aneja)</title><link>http://blogs.msdn.com/vbteam/archive/2009/11/16/spot-the-bug-the-key-to-using-anonymous-types-jonathan-aneja.aspx</link><pubDate>Tue, 17 Nov 2009 07:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923427</guid><dc:creator>VBTeam</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9923427.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9923427</wfw:commentRss><description>&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT face=Calibri&gt;This one’s going to be long, but for those of you who’ve felt the first 3 &lt;A href="http://blogs.msdn.com/vbteam/archive/tags/Spot+the+Bug_2100_/default.aspx" mce_href="http://blogs.msdn.com/vbteam/archive/tags/Spot+the+Bug_2100_/default.aspx"&gt;in this series&lt;/A&gt; were too easy I promise this one’s tougher &lt;/FONT&gt;&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Let’s say you want to list all the customers from a table in a ComboBox, and update the UI based on which one is selected.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To do this we’ll need to bring back two fields from the database – the customer’s name and the customer’s ID.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When a customer is selected we want the ComboBox’s SelectedValue property to equal the customer’s ID.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Here’s some quick code that gets us up and running (using Northwind and LINQ to SQL):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; db &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; NorthwindDataContext&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; query = &lt;SPAN style="COLOR: blue"&gt;From&lt;/SPAN&gt; row &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; db.Customers _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Select&lt;/SPAN&gt; row.CompanyName, row.CustomerID&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ComboBox1.DataSource = query.ToList()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ComboBox1.DisplayMember = &lt;SPAN style="COLOR: #a31515"&gt;"CompanyName"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ComboBox1.ValueMember = &lt;SPAN style="COLOR: #a31515"&gt;"CustomerID"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;But now let’s say your boss looks at the app and says “I want you to add an ‘All Customers’ option as the first item in the list.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;How would you do that?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You’d need to insert an anonymous type into an existing sequence of anonymous types, which is tricky given that you can never actually use the type’s name.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Thankfully there’s a trick that uses generic parameter inference that allows us to do this (it relies on the fact that the compiler will share (or “unify”) the definition of multiple anonymous types when they have the same number of members, in the same order, of the same type, with the same names, and the same mutability):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; db &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; NorthwindDataContext&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; query = &lt;SPAN style="COLOR: blue"&gt;From&lt;/SPAN&gt; row &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; db.Customers _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Select&lt;/SPAN&gt; row.CompanyName, row.CustomerID&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; allOption = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;With&lt;/SPAN&gt; {.CompanyName = &lt;SPAN style="COLOR: #a31515"&gt;"All Customers"&lt;/SPAN&gt;, _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;.CustomerID = &lt;SPAN style="COLOR: #a31515"&gt;"-1"&lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ComboBox1.DataSource = AddOptionForAll(query, allOption).ToList()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ComboBox1.DisplayMember = &lt;SPAN style="COLOR: #a31515"&gt;"CompanyName"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ComboBox1.ValueMember = &lt;SPAN style="COLOR: #a31515"&gt;"CustomerID"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;...&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; AddOptionForAll(&lt;SPAN style="COLOR: blue"&gt;Of&lt;/SPAN&gt; T)(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sequence &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; IEnumerable(&lt;SPAN style="COLOR: blue"&gt;Of&lt;/SPAN&gt; T), _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; allOption &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; T) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; IEnumerable(&lt;SPAN style="COLOR: blue"&gt;Of&lt;/SPAN&gt; T)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'wrap individual element in an array and then union the two sequences&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; (&lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; T() {allOption}).Union(sequence)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;As long as we have an anonymous type that’s compatible with the anonymous type that the query generated, the compiler will determine that &lt;I style="mso-bidi-font-style: normal"&gt;sequence &lt;/I&gt;and &lt;I style="mso-bidi-font-style: normal"&gt;allOption&lt;/I&gt; are actually the same type and this should work fine.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Ok so let’s get to the bug – well in this case &lt;I style="mso-bidi-font-style: normal"&gt;spotting &lt;/I&gt;it is pretty simple (it doesn’t compile &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;), but fixing it is tricky (though I’ve already given two pretty big hints). &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Here’s the text of the compiler error (it’s on the line that calls AddOptionForAll):&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Data type(s) of the type parameter(s) in method 'Public Function AddOptionForAll(Of T)(sequence As System.Collections.Generic.IEnumerable(Of T), allOption As T) As System.Collections.Generic.IEnumerable(Of T)' cannot be inferred from these arguments because they do not convert to the same type. Specifying the data type(s) explicitly might correct this error.&lt;SPAN style="mso-tab-count: 1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;What’s wrong and how do we fix it?&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Answer:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/B&gt;We actually told the compiler to generate two &lt;I style="mso-bidi-font-style: normal"&gt;different&lt;/I&gt; anonymous type definitions, and thus it can’t unify them because the types really are different.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;From earlier: “…the compiler will share (or “unify”) the definition of multiple anonymous types when they have the same number of members, in the same order, with the same names, and &lt;B style="mso-bidi-font-weight: normal"&gt;the same mutability&lt;/B&gt;”&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;The anonymous type that the query generates will have ReadOnly properties, whereas the anonymous type that we generated (allOption) will have Read/Write properties.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The fix is to allOption immutable so that its structure will match the result of the query:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; allOption = &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;With&lt;/SPAN&gt; {&lt;SPAN style="BACKGROUND: yellow; COLOR: blue; mso-highlight: yellow"&gt;Key&lt;/SPAN&gt; .CompanyName = &lt;SPAN style="COLOR: #a31515"&gt;"All Customers"&lt;/SPAN&gt;, _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="BACKGROUND: yellow; COLOR: blue; mso-highlight: yellow"&gt;Key&lt;/SPAN&gt; .CustomerID = &lt;SPAN style="COLOR: #a31515"&gt;"-1"&lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;The “Key” modifier tells the compiler to make those properties ReadOnly and to override Equals and GetHashCode such that they only consider “Key” properties when deciding if two instances of the same anonymous type are equal.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(the other hint was in the title &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;For the query above, the compiler automatically inserts the “Key” modifier - i.e. what we wrote is exactly equivalent to this:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; query = &lt;SPAN style="COLOR: blue"&gt;From&lt;/SPAN&gt; row &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; db.Customers _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Select&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;With&lt;/SPAN&gt; {&lt;SPAN style="COLOR: blue"&gt;Key&lt;/SPAN&gt; row.CompanyName, &lt;SPAN style="COLOR: blue"&gt;Key&lt;/SPAN&gt; row.CustomerID}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;So with a simple fix to the allOption line we’re now using the same anonymous type definition and everything works fine.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;VB’s anonymous type syntax is very flexible and provides three different options: immutable, fully mutable, or partially mutable (i.e. some fields are ReadOnly while others are not).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Even for a simple scenario like adding an option to a list, the better you understand how things work under the covers the easier it’ll be to debug problems later &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923427" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/LINQ_2F00_VB9/default.aspx">LINQ/VB9</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Jonathan+Aneja/default.aspx">Jonathan Aneja</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2005/default.aspx">VB2005</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/IQueryable/default.aspx">IQueryable</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Spot the Bug! – Is it in VB or XAML? (Jonathan Aneja)</title><link>http://blogs.msdn.com/vbteam/archive/2009/11/12/spot-the-bug-is-it-in-vb-or-xaml-jonathan-aneja.aspx</link><pubDate>Fri, 13 Nov 2009 03:39:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9921740</guid><dc:creator>VBTeam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9921740.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9921740</wfw:commentRss><description>&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;What’s wrong with the following WPF code?&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Class&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; Window1 &lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Sub&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; OK_Click(sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Object&lt;/SPAN&gt;, e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; RoutedEventArgs) &lt;SPAN style="COLOR: blue"&gt;Handles &lt;/SPAN&gt;OK.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"Button Clicked"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;End&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: blue"&gt;Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Window&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; x&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;:&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Class&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;="Window1"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;xmlns&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;:&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;x&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Title&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="Window1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt; Height&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="300"&lt;/SPAN&gt;&lt;SPAN style="COLOR: red"&gt; Width&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;="300"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Grid&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; Name&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;="OK"&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; Click&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;="OK_Click"&amp;gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;OK&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Button&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Grid&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Window&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Answer: &lt;/B&gt;The message box will be displayed twice!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To understand why, open up the project in Reflector, and in the System_Windows_Mark_IComponentConnector_Connect method you’ll see these two lines:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: #1000a0"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Me&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;A title="Property WpfApplication1.Window1.OK As Button" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WpfDoubleEvent:1.0.0.0/WpfApplication1.Window1/property:OK:System.Windows.Controls.Button"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;OK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt; = &lt;SPAN style="COLOR: #1000a0"&gt;DirectCast&lt;/SPAN&gt;(target, &lt;/FONT&gt;&lt;A title=System.Windows.Controls.Button href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Button"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;Button&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;)&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #1000a0"&gt;AddHandler Me&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;A title="Property WpfApplication1.Window1.OK As Button" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WpfDoubleEvent:1.0.0.0/WpfApplication1.Window1/property:OK:System.Windows.Controls.Button"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;OK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;.&lt;/FONT&gt;&lt;A title="Event System.Windows.Controls.Primitives.ButtonBase.Click As RoutedEventHandler" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.ButtonBase/event:Click:System.Windows.RoutedEventHandler"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;Click&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;, &lt;SPAN style="COLOR: #1000a0"&gt;New &lt;/SPAN&gt;&lt;/FONT&gt;&lt;A title=System.Windows.RoutedEventHandler href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationCore:3.0.0.0:31bf3856ad364e35/System.Windows.RoutedEventHandler"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;RoutedEventHandler&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;(&lt;SPAN style="COLOR: #1000a0"&gt;AddressOf Me&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;A title="WpfApplication1.Window1.OK_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WpfDoubleEvent:1.0.0.0/WpfApplication1.Window1/OK_Click(Object,System.Windows.RoutedEventArgs)"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;OK_Click&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;)&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Ok so we’re adding one handler here, but click the link to navigate to “OK”.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You’ll see this is actually a &lt;I style="mso-bidi-font-style: normal"&gt;property&lt;/I&gt; of type Button (that’s what the compiler does for WithEvents/Handles – the full story of how WithEvents works is its own blog entry…).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In the Setter you’ll see this code:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="COLOR: #1000a0"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN style="COLOR: #1000a0"&gt;Not&lt;/SPAN&gt; &lt;SPAN style="COLOR: #1000a0"&gt;Me&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;A title="_OK As Button" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WpfDoubleEvent:1.0.0.0/WpfApplication1.Window1/_OK:System.Windows.Controls.Button"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;_OK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt; &lt;SPAN style="COLOR: #1000a0"&gt;Is&lt;/SPAN&gt; &lt;SPAN style="COLOR: maroon"&gt;Nothing&lt;/SPAN&gt;) &lt;SPAN style="COLOR: #1000a0"&gt;Then&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT face="Courier New"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #1000a0"&gt;AddHandler Me&lt;/SPAN&gt;.&lt;/FONT&gt;&lt;A title="_OK As Button" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://WpfDoubleEvent:1.0.0.0/WpfApplication1.Window1/_OK:System.Windows.Controls.Button"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;_OK&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;.&lt;/FONT&gt;&lt;A title="Event System.Windows.Controls.Primitives.ButtonBase.Click As RoutedEventHandler" href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://PresentationFramework:3.0.0.0:31bf3856ad364e35/System.Windows.Controls.Primitives.ButtonBase/event:Click:System.Windows.RoutedEventHandler"&gt;&lt;FONT color=#0000ff face="Courier New"&gt;Click&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;, handler&lt;/FONT&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;FONT face="Courier New"&gt; &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: #1000a0"&gt;End If&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;So now we can clearly see there’s two AddHandler calls and thus the event gets handled multiple times by the same method (which is perfectly legal).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;One of them came from &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Handles &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;OKButton.Click&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;, and the other came from &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;Click&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;="OK_Click"&lt;/SPAN&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;I style="mso-bidi-font-style: normal"&gt;The key thing to realize is that if you wire up the eventhandler in XAML, don’t wire it up in code using Handles (and vice-versa).&lt;/I&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Thankfully in this scenario it’s obvious that there’s a problem because there’s a message box, but if the eventhandler was doing something more subtle (such as incrementing a counter or modifying some other state), this can lead to hard-to-diagnose bugs.&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9921740" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Jonathan+Aneja/default.aspx">Jonathan Aneja</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2005/default.aspx">VB2005</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Spot+the+Bug_2100_/default.aspx">Spot the Bug!</category></item><item><title>Spot the Bug! – Much ado about Nothing… Part 2! (Jonathan Aneja)</title><link>http://blogs.msdn.com/vbteam/archive/2009/11/05/spot-the-bug-much-ado-about-nothing-part-2-jonathan-aneja.aspx</link><pubDate>Fri, 06 Nov 2009 07:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9918435</guid><dc:creator>VBTeam</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9918435.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9918435</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;In &lt;A href="http://blogs.msdn.com/vbteam/archive/2009/11/03/spot-the-bug-much-ado-about-nothing-jonathan-aneja.aspx" mce_href="http://blogs.msdn.com/vbteam/archive/2009/11/03/spot-the-bug-much-ado-about-nothing-jonathan-aneja.aspx"&gt;yesterday’s&lt;/A&gt; post we saw that the use of the wrong comparison operator with Nothing in an If block can lead to surprising results.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Let’s look at a slightly different case today:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; x &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; x = &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"A true statement - we land here"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"The statement is a lie - we land here"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT face=Calibri&gt;&lt;FONT size=3&gt;What gets printed?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;If the code is intended to print “A true statement…”, &lt;I style="mso-bidi-font-style: normal"&gt;is there actually a bug in this code?&lt;o:p&gt;&lt;/o:p&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Answer:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/B&gt;The code is correct according to its “specification” (I’m using the term loosely here &lt;/FONT&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT face=Calibri&gt;), so from a technical point of view there is no bug here.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;I style="mso-bidi-font-style: normal"&gt;However&lt;/I&gt;, from a code readability and maintenance point of view, I’d argue that there is a bug.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;The Nothing literal in VB means “default value for this type”, and for an Integer that would be 0.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So the code above is &lt;I style="mso-bidi-font-style: normal"&gt;exactly&lt;/I&gt; equivalent to this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Dim&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt; x &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0&lt;SPAN style="COLOR: blue"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; x = 0 &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"A true statement - we land here"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"The statement is a lie - we land here"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now that’s &lt;I style="mso-bidi-font-style: normal"&gt;way &lt;/I&gt;more readable than the version above, and dramatically reduces the potential for confusion.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In general*, if you ever find yourself writing “= Nothing” in a conditional expression, you should either be changing the = to “Is” (as we saw yesterday), or you should change Nothing to the actual default value if possible.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3&gt;The next post will have a real bug, I promise &lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;FONT size=3&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 8pt"&gt;&lt;FONT face=Calibri&gt;*Yes, there may be cases such as structure/generics/overloaded operators where you actually would want to say “= Nothing” – my point is that if you’re going to do this make sure you know what you’re doing, and insert a comment so that those reading your code also know what you’re doing &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-FAMILY: Wingdings; FONT-SIZE: 8pt; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri; mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;&lt;SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings"&gt;J&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-SIZE: 8pt"&gt;&lt;FONT face=Calibri&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918435" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Jonathan+Aneja/default.aspx">Jonathan Aneja</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2005/default.aspx">VB2005</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Spot+the+Bug_2100_/default.aspx">Spot the Bug!</category></item><item><title>Spot the Bug! – Much Ado about Nothing… (Jonathan Aneja)</title><link>http://blogs.msdn.com/vbteam/archive/2009/11/03/spot-the-bug-much-ado-about-nothing-jonathan-aneja.aspx</link><pubDate>Wed, 04 Nov 2009 02:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9917101</guid><dc:creator>VBTeam</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9917101.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9917101</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;&lt;FONT size=3&gt;Microsoft has this neat mailing list called “Spot the Bug” where developers can send interesting snippets of code that look correct but actually have subtle bugs in them.&amp;nbsp; The puzzles are a lot of fun and I’ve always thought it’d be a fun thing to try here on the team blog.&amp;nbsp; Over the past year or so I’ve been keeping a list of interesting bug reports and emails where people have been tripped up by some of VB’s hidden subtleties (though admittedly many of these could apply to C# as well).&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;&lt;o:p&gt;&lt;FONT size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;&lt;FONT size=3&gt;The format’s gonna be a bit of an experiment – let me know if you prefer to see the answer in the same post or posted a day later.&amp;nbsp; Alright let’s get started…&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;SPAN style="mso-ansi-language: EN" lang=EN&gt;&lt;FONT size=3&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;&lt;STRONG&gt;Spot the Bug:&lt;/STRONG&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;The following code is intended to print “Yes” – will it?&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; x &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;? = &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; x = &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"Yes: x contains null"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"No: x does not contain null, and has a real value"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Answer:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/B&gt;No!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We’re using the equality operator to compare a nullable integer with Nothing – this results in &lt;I style="mso-bidi-font-style: normal"&gt;null propagation&lt;/I&gt;, i.e. the result of the expression is Nothing.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;An If-statement attempts to convert its condition to a Boolean, so basically we’re left with this:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;'Obviously we'll always land here&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;This can be really surprising when working with nullables, so we’ve decided to add a warning for this case in VB10:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;IMG style="WIDTH: 628px; HEIGHT: 206px" title="New null-popagation warning in VB10" alt="New null-popagation warning in VB10" src="http://blogs.msdn.com/photos/vbteam_gallery2/images/9917103/original.aspx" width=628 height=206 mce_src="http://blogs.msdn.com/photos/vbteam_gallery2/images/9917103/original.aspx"&gt;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;SPAN style="mso-no-proof: yes"&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /&gt;&lt;v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt;&lt;/v:path&gt;&lt;o:lock aspectratio="t" v:ext="edit"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;v:shape style="WIDTH: 468pt; HEIGHT: 151.5pt; VISIBILITY: visible; mso-wrap-style: square" id=Picture_x0020_1 type="#_x0000_t75" o:spid="_x0000_i1025"&gt;&lt;v:imagedata mce_src="file:///C:\Users\jonaneja\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png" o:title="" src="file:///C:\Users\jonaneja\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;&lt;FONT size=3 face=Calibri&gt;The warning explains the fix – use “Is” instead of = to avoid the null propagation and get the semantics you expect:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; x &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;? = &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; x &lt;SPAN style="BACKGROUND: yellow; COLOR: blue; mso-highlight: yellow"&gt;Is&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt; Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"Yes: x contains null"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"No: x does not contain null, and has a real value"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;&lt;SPAN style="COLOR: blue"&gt;&lt;FONT color=#000000&gt;&lt;FONT size=3 face=Calibri&gt;&lt;o:p&gt;
&lt;P style="MARGIN: 0in 0in 0pt" class=MsoNoSpacing&gt;Check back for a similar case but with a bit of a twist tomorrow...&lt;/P&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9917101" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Jonathan+Aneja/default.aspx">Jonathan Aneja</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2005/default.aspx">VB2005</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Spot+the+Bug_2100_/default.aspx">Spot the Bug!</category></item><item><title>Visual Basic “How Do I” Videos</title><link>http://blogs.msdn.com/vbteam/archive/2009/10/21/visual-basic-how-do-i-videos.aspx</link><pubDate>Thu, 22 Oct 2009 01:23:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9911041</guid><dc:creator>VBTeam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9911041.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9911041</wfw:commentRss><description>&lt;p&gt;We’ve started two &lt;a href="http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx#vblang"&gt;new “How Do I” videos series&lt;/a&gt; on the &lt;a href="http://msdn.com/vbasic"&gt;Visual Basic Developer Center&lt;/a&gt;. More to come, but here’s the latest!     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/vbasic/bb466226.aspx#vblang"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VisualBasicHowDoIVideos_10273/image_3.png" width="629" height="972" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="wlWriterHeaderFooter" style="margin:0px; padding:0px 0px 0px 0px;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;
&lt;/script&gt;
&lt;script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/script&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911041" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Lisa+Feigenbaum/default.aspx">Lisa Feigenbaum</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Announcing Visual Studio 2010 Beta 2!</title><link>http://blogs.msdn.com/vbteam/archive/2009/10/20/announcing-visual-studio-2010-beta-2.aspx</link><pubDate>Tue, 20 Oct 2009 17:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9910058</guid><dc:creator>VBTeam</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9910058.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9910058</wfw:commentRss><description>&lt;P&gt;There were a lot of Microsoft &lt;A href="http://www.microsoft.com/presspass/press/2009/oct09/10-19vsfinalstretchpr.mspx" mce_href="http://www.microsoft.com/presspass/press/2009/oct09/10-19vsfinalstretchpr.mspx"&gt;announcements&lt;/A&gt; that happened yesterday! Many of these happened during Steve Ballmer’s keynote at the &lt;A href="http://www.mssharepointconference.com/pages/default.aspx" mce_href="http://www.mssharepointconference.com/pages/default.aspx"&gt;SharePoint Developers Conference&lt;/A&gt; (&lt;A href="http://www.mssharepointconference.com/pages/default.aspx" mce_href="http://www.mssharepointconference.com/pages/default.aspx"&gt;Video&lt;/A&gt;, &lt;A href="http://twitter.com/#search?q=%23SPC09" mce_href="http://twitter.com/#search?q=%23SPC09"&gt;Twitter&lt;/A&gt;). Here is the list:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://go.microsoft.com/fwlink/?LinkID=151797" mce_href="http://go.microsoft.com/fwlink/?LinkID=151797"&gt;Visual Studio 2010 Beta 2&lt;/A&gt; and compatible versions of &lt;A href="http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33305" mce_href="http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33305"&gt;IronRuby&lt;/A&gt;/&lt;A href="http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125" mce_href="http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125"&gt;IronPython&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;Visual Studio 2010 Tools for SharePoint (&lt;A href="http://www.mssharepointconference.com/pages/default.aspx" mce_href="http://www.mssharepointconference.com/pages/default.aspx"&gt;Keynote&lt;/A&gt;, &lt;A href="http://msdn.microsoft.com/en-us/sharepoint/default.aspx" mce_href="http://msdn.microsoft.com/en-us/sharepoint/default.aspx"&gt;Dev Center&lt;/A&gt;) &lt;/LI&gt;
&lt;LI&gt;New Visual Studio logo and brand (blue &amp;amp; purple infinity sign) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx#compare" mce_href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx#compare"&gt;Visual Studio 2010 SKU Simplification to Professional, Premium, Ultimate&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.com/" mce_href="http://msdn.com/"&gt;MSDN.com website refresh&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/somasegar/archive/2009/10/19/announcing-visual-studio-2010-and-net-fx-4-beta-2.aspx" mce_href="http://blogs.msdn.com/somasegar/archive/2009/10/19/announcing-visual-studio-2010-and-net-fx-4-beta-2.aspx"&gt;Visual Studio 2010 Launch date on 3/22/2010&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;MSDN subscribers can &lt;A href="http://go.microsoft.com/fwlink/?LinkID=151797" mce_href="http://go.microsoft.com/fwlink/?LinkID=151797"&gt;download Beta 2&lt;/A&gt; now!&amp;nbsp; We will be opening up Beta 2 for everyone to download starting this Wednesday. &lt;/P&gt;
&lt;P&gt;In honor of VS 2010 Beta 2, we have a lot of great content prepared. The following MSDN page aggregates our VB 2010 content.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;B&gt;&lt;A href="http://msdn.microsoft.com/en-us/vbasic/dd819153.aspx" mce_href="http://msdn.microsoft.com/en-us/vbasic/dd819153.aspx"&gt;Visual Basic 2010 Resources&lt;/A&gt;&lt;/B&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;We hope you will enjoy trying out the next release! We definitely look forward to hearing your feedback. Here are some places where you can contact us:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;For Questions:&lt;/STRONG&gt; &lt;A href="http://social.msdn.microsoft.com/Forums/en-US/category/visualbasic" mce_href="http://social.msdn.microsoft.com/Forums/en-US/category/visualbasic"&gt;Visual Basic Forums&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;For Bugs&lt;/STRONG&gt;: &lt;A href="http://connect.microsoft.com/" mce_href="http://connect.microsoft.com"&gt;Microsoft Connect&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;For General Observations or Comments:&lt;/STRONG&gt; In the Comments to this Blog&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;Thanks! &lt;BR&gt;Lisa&lt;/P&gt;
&lt;DIV style="PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px" class=wlWriterHeaderFooter&gt;&lt;BR&gt;&lt;BR&gt;
&lt;SCRIPT type=text/javascript&gt;
&lt;/SCRIPT&gt;

&lt;SCRIPT type=text/javascript src="http://tweetmeme.com/i/scripts/button.js" mce_src="http://tweetmeme.com/i/scripts/button.js"&gt;&lt;/SCRIPT&gt;
&lt;/DIV&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9910058" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Lisa+Feigenbaum/default.aspx">Lisa Feigenbaum</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Getting Loopy (Matt Gertz)</title><link>http://blogs.msdn.com/vbteam/archive/2009/10/07/getting-loopy-matt-gertz.aspx</link><pubDate>Thu, 08 Oct 2009 00:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9904606</guid><dc:creator>VBTeam</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9904606.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9904606</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In my last post, I talked about the hidden costs that can occur whenever you call out to methods, particularly in loops.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In looking at my examples, reader KG2V commented that another thing that folks need to be aware of is avoiding the assumption that the world (or, in this case, a list) is a static thing.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s a good point and it deserves some attention, particularly given that different languages will react in different ways to change.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;To illustrate this point, let’s assume that we have a form with a ListBox on it, and that we also have a button on the form that, when clicked, runs the following VB code:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Bad -- don't do this&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; Button1_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;Handles&lt;/SPAN&gt; Button1.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; i &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0 &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; ListBox1.Items.Count - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ListBox1.Items.RemoveAt(i)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Ostensibly, we want to remove all of the items from the ListBox. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;(Yes, normally we’d use Clear() to do that, but stay with me for a moment; &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;I’ll switch to more “real” cases in a few paragraphs.)&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But if we run this code, we’ll get an exception.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Why?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Because whenever we remove an object, all of the indices of the objects after it will decrease by 1.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Let’s assume that there are three objects in the list - &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;A, B, and C – so that Count=3:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;When i = 0, we’ll remove the object at index 0, which is A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;B now moves to index 0, and C now moves to index 1.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;When i = 1, we’ll remove the object at index 1, which is C.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There is nothing after C, so nothing else changes.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;When i =2, we’ll remove the object at index 2, which is… nothing.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There’s only one object left, which is B, and it’s at index 0.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So, we get an out-of-bounds exception.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In VB (as was pointed out to me in the comments section of my last point), the value of Count is only assessed once, right when the loop is encountered, so we will always loop through (in this case) three times.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;But is the lack of reevaluation of Count the only issue?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Maybe not.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Let’s try the same method in C#, in which Count is evaluated on every iteration:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;// Bad -- don't do this.&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;void&lt;/SPAN&gt; button1_Click(&lt;SPAN style="COLOR: blue"&gt;object&lt;/SPAN&gt; sender, &lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt; e)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; i;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;for&lt;/SPAN&gt; (i = 0; i &amp;lt; listBox1.Items.Count; i++)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;listBox1.Items.RemoveAt(i);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;When i = 0, we’ll remove the object at index 0, which is A.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;B now moves to index 0, and C now moves to index 1.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1in; mso-list: l0 level2 lfo1; mso-add-space: auto" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;o&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Now, we’ll loop back to the top.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The value of i becomes 1, and the value of Count becomes 2.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The stop condition is not met, so we keep going.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpMiddle&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;When i = 1, we’ll remove the object at index 1, which is C.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;There is nothing after C, so nothing else changes.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 1in; mso-list: l0 level2 lfo1; mso-add-space: auto" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Courier New'"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;o&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Again, we loop back to the top.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The value of i becomes 2, and the value of Count becomes 1.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The stop condition is met, and we exit the loop.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;So, although no exception is thrown, the method also fails in C# -- B is left behind.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So, the problem isn’t whether or not Count is evaluated; it’s that the elements in the list are changing indices on each deletion.&lt;/FONT&gt;&lt;/P&gt;
&lt;H2 style="MARGIN: 10pt 0in 0pt"&gt;&lt;FONT color=#4f81bd size=4 face=Cambria&gt;Sometimes doing things backwards is good&lt;/FONT&gt;&lt;/H2&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This is why, in the case where multiple removals need to be made on an indexed list, a smart programmer (all of whom are yawning right now as they read this) will work backwards.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That is, they start with the largest index and work down towards zero. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;For example, imagine that we want to remove the 4&lt;SUP&gt;th&lt;/SUP&gt;, 7&lt;SUP&gt;th&lt;/SUP&gt;, and 9&lt;SUP&gt;th&lt;/SUP&gt; element from a list.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We don’t want to do it this way:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Bad -- don't do this&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;ListBox1.Items.RemoveAt(4)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;ListBox1.Items.RemoveAt(7)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;ListBox1.Items.RemoveAt(9)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Once we’ve removed the 4&lt;SUP&gt;th&lt;/SUP&gt; item, then the element at 7 will have moved to 6 and the element at 9 will have moved to 8.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;After we’ve removed the new 7&lt;SUP&gt;th&lt;/SUP&gt; item, the element at 8 will move to 7, and so on.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We’d either be removing the wrong elements or we’d crash.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s far better to do them in reverse order:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;ListBox1.Items.RemoveAt(9)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;ListBox1.Items.RemoveAt(7)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;ListBox1.Items.RemoveAt(4)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 0pt 0.5in" class=MsoNoSpacing&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;None of the indices up front will be affected by changes that are occurring behind them in the list – their indices won’t change, and this will work fine.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;This issue comes up when you are (for example) deleting items from a listbox that supports multiselection.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You basically have two ways to get the selected items in a listbox: you can use the SelectedIndices member function, which returns a collection of indices, or you can use SelectedItems, which returns a collection of selected items.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Given either collection, there’s no way to say “remove all of these.” There &lt;B style="mso-bidi-font-weight: normal"&gt;is&lt;/B&gt; a “Remove” command on the resulting collections, but if you use it, you’ll just be removing the item from *that* collection and not from the ListBox, which has its own collection of items – essentially, you’ll just deselect the items.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;So, what do you do?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;At first, it looks like you have two options; you could try removing them from the master list based on item, or based on object.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Let’s look at removal based on the item:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Bad -- don't do this&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Each&lt;/SPAN&gt; index &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; ListBox1.SelectedIndices&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ListBox1.Items.RemoveAt(index)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This won’t work.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The selected indices are in numerical order (no matter in which order you selected them), so you’ll be sliding indices on each deletion and will subsequently delete the wrong things.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You won’t crash if you overreach on an index, because the For…Each loop will check for Nothing when it does a MoveNext internally and will exit gracefully, but this is actually worse since it may take longer before you notice a problem!&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;This won’t work either, and will potentially crash:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Bad -- don't do this&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; index &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0 &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; ListBox1.SelectedIndices.Count - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ListBox1.Items.RemoveAt(ListBox1.SelectedIndices(index))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Again, the indices for the downstream objects will decrease, you’ll delete the wrong things, and you’ll likely crash.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;You can, however, iterate down instead, as long as you are confident that the selected indices are in numerical order (as they will be in this case):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' This works:&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; index &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = ListBox1.SelectedIndices.Count - 1 &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; 0 &lt;SPAN style="COLOR: blue"&gt;Step&lt;/SPAN&gt; -1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ListBox1.Items.RemoveAt(ListBox1.SelectedIndices(index))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Having found something that works via iteration, let’s now consider the enumeration angle instead.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In general, I prefer to enumerate lists whenever possible instead of iterating through them.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is not one of those times, though. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Consider this code, which will fail:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Bad -- don't do this&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Each&lt;/SPAN&gt; item &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; ListBox1.SelectedItems&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ListBox1.Items.Remove(item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;“Well, c’mon, why doesn’t &lt;I style="mso-bidi-font-style: normal"&gt;this&lt;/I&gt; work?” I hear you cry.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;“I don’t care about indices in this case, I’m not even using them; I’m just removing specific items.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;True, but if you run this code, you will indeed get an exception essentially stating that the collection has been modified and the list of selected items is no longer valid for enumeration.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;We can’t work around this by assigning the collection of selected items to another variable and enumerating on that, since that just creates a reference to the same collection.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In order for it to work, you’ve have to get the references out of the collection itself so that the ListBox is no longer part of the equation on the removal loop’s assessment.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Really, this is just silly -- don't ever do this&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; selItems &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Collection&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Each&lt;/SPAN&gt; item &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; ListBox1.SelectedItems&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;selItems.Add(item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Each&lt;/SPAN&gt; item &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; selItems&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ListBox1.Items.Remove(item)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Functionally, this will work; however, you shouldn’t do it for two reasons:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpFirst&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;First of all, it’s stupid – you have to loop through twice.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Occasionally, I do need to clone lists, like when creating an editable list from a read-only list – I’ve done that in a previous blogpost on this site, in fact.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;But my motives are not so noble here; I’m using this for no other reason than allowing enumeration to work.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1" class=MsoListParagraphCxSpLast&gt;&lt;SPAN style="FONT-FAMILY: Symbol; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol"&gt;&lt;SPAN style="mso-list: Ignore"&gt;&lt;FONT size=3&gt;·&lt;/FONT&gt;&lt;SPAN style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;FONT size=3 face=Calibri&gt;Second, each call to RemoveItem has a hidden cost – namely, the list has got to go find that item.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In this case, you can bet that there’s good hashing going on that doesn’t make that as painful as it might be, but do you really want to count on that, given the better numeric alternative above?&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;No, just there’s really no good way to do removal by enumeration that I’ve ever found.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And since each object is totally clueless about whether it itself is selected or not, you can’t even enumerate through the collection yourself and delete it if it’s marked as selected.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Of course, I’ve just talked about deletions, since they are more interesting than additions due to the crash potential.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;However, additions can also mess you up in a loop due to similar index changes, and I’ve actually run into cases where a list may have both insertions and deletions done, so that I wasn’t even able to leverage the change in list size as a clue to figure out what had happened to the data.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The bottom line is, whenever doing an operation within a loop, you need to understand whether or not that operation will collide with your loop conditions and assumptions.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Generally, you control this in your code, but in multithreaded environments, where changes to an existing store of data might be made from a different thread “simultaneously” with your thread, you really need to understand how thread-safe your code is with respect to data changes.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(But that is a story for another time.)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;‘Til next time,&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;--Matt--*&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9904606" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Matt+Gertz/default.aspx">Matt Gertz</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2005/default.aspx">VB2005</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Hidden Costs (Matt Gertz)</title><link>http://blogs.msdn.com/vbteam/archive/2009/10/06/hidden-costs-matt-gertz.aspx</link><pubDate>Tue, 06 Oct 2009 22:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9903925</guid><dc:creator>VBTeam</dc:creator><slash:comments>15</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9903925.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9903925</wfw:commentRss><description>&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;(Note: there was a grievous error in this post based on a bad assumption on my art regarding VB.&amp;nbsp; Not feeling the need to hide my ignorance :-), I have instead made a number of edits in this post to bring it back to some semblance of reality.)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;One thing that gets me annoyed with myself is realizing that the product or service I’ve just bought has some hidden costs that I didn’t anticipate.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It might be as complicated as realizing that my plane ticket has all sorts of byzantine surcharges and luggage costs, or as simple as making budgeting for a new killer gaming PC and forgetting about the sales tax – it seems that there are always extra costs out there that will come back to bite you.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Being (as I have said in past postings to this blog) an inherently lazy person, and being fully caught up in our “I must have the sparkly thing &lt;I style="mso-bidi-font-style: normal"&gt;right now&lt;/I&gt;” culture, I’m apt to overlook the fine print in any purchase agreement unless I really force myself to slow down and pay attention to the details.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;One of the times I really have to pay attention is when I’m reviewing code here at Microsoft.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As a member of the release team that makes the final decisions as to what last-minute fixes are safe enough to be applied to an imminent release, it’s my job to take a look at the proposed fix and make sure that it doesn’t introduce more problems than it purports to solve – i.e., that it doesn’t add hidden costs.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;On the rare occasion that I find a problem in someone’s code, it’s usually something that’s obviously dysfunctional – a case where a variable isn’t initialized properly, or where a different team has simultaneously made a change that will render this change dangerous.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But some of the problems are more subtle, and might not be obvious if only minimal testing and review has been done.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Consider the following code (very similar to a case I reviewed here at work the other day):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; MyList &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;List&lt;/SPAN&gt;(&lt;SPAN style="COLOR: blue"&gt;Of&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;)&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; Button1_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;Handles&lt;/SPAN&gt; Button1.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Text.&lt;SPAN style="COLOR: #2b91af"&gt;StringBuilder&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; i &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0 &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; MyList.Count - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s.Append(MyList(i))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Edit&lt;/B&gt;:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This is an error in my blog post &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;– I hadn’t realized that VB, unlike many other languages, only gets the value of the stop condition once (thanks to Phil Wells for pointing this out).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;To make my point, I would have to be using code like this:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: #d9d9d9; mso-layout-grid-align: none; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Text.&lt;SPAN style="COLOR: #2b91af"&gt;StringBuilder&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: #d9d9d9; mso-layout-grid-align: none; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; i &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: #d9d9d9; mso-layout-grid-align: none; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Do&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;While&lt;/SPAN&gt; i &amp;lt; MyList.Count() - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: #d9d9d9; mso-layout-grid-align: none; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s.Append(MyList(i))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: #d9d9d9; mso-layout-grid-align: none; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;i += 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: #d9d9d9; mso-layout-grid-align: none; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Loop&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; BACKGROUND: #d9d9d9; mso-layout-grid-align: none; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 11pt; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-bidi; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;The method Count() might still have a hidden cost, but in the For Loop case, I’m at least only hitting it once.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;The fact that VB only analyzes the stop condition once leads to a different issue to be aware of that I’ll cover in my next blog.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Seems pretty simple, yes?&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;When a button is clicked, the code iterates through the strings in a list and appends them to a StringBuilder, creating (for whatever reason) one long string containing all of the contents.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And, to cursory appearances, it will function correctly. &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;However, the code has hidden costs.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You see, written this way, the value MyList.Count is going to be reevaluated on every iteration of the “For” loop, even though the value itself isn’t changing.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Furthermore, my indexing into MyList, which is always with reference to the beginning of the list, will also have a non-zero impact.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;This impacts the performance of the code and will make my customers unhappy over the sloth-like operation of my application.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;In this case, the cost isn’t really high, as Count() is a property wrapping something that’s stored as a private integer member, and index referencing also has tricks to speed it up, but there’s still a cost and it can add up.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s even worse if the Count() call has to be calculated!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Consider this really awful code where I’ve created my own “List” type:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Class&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' For some unknown reason, I'm creating my own linked list instead of using a List(Of) generic.&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' Please don't do this for real!&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; data &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; NextMLO &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; Insert(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; mlo &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; NextMLO &lt;SPAN style="COLOR: blue"&gt;IsNot&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;NextMLO = mlo&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;mlo.NextMLO = NextMLO.NextMLO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;NextMLO.NextMLO = mlo&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End If&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; Count() &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; ct &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; current &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;/SPAN&gt; = &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Do&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;While&lt;/SPAN&gt; current &lt;SPAN style="COLOR: blue"&gt;IsNot&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ct += 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;current = current.NextMLO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Loop&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; ct&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt; Item(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; index &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; index &amp;gt;= Count() &lt;SPAN style="COLOR: blue"&gt;OrElse&lt;/SPAN&gt; index &amp;lt; 0 &lt;SPAN style="COLOR: blue"&gt;Then&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; current &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;/SPAN&gt; = &lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; i &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0 &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; index - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;current = current.NextMLO&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Return&lt;/SPAN&gt; current&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Function&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Class&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; MyLameObjectHeader &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; MyLameObjectHeader &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;MyLameObject&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; Button1_Click(&lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; sender &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;Object&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;ByVal&lt;/SPAN&gt; e &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; System.&lt;SPAN style="COLOR: #2b91af"&gt;EventArgs&lt;/SPAN&gt;) _&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 8pt"&gt;Handles&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt; Button1.Click&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Text.&lt;SPAN style="COLOR: #2b91af"&gt;StringBuilder&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; i &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0 &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; MyLameObjectHeader.Count - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s.Append(MyLameObjectHeader.Item(i))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 8pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Perhaps as a school assignment, I’ve created a singly-linked list which contains objects of type “MyLameObject” (instead of using optimized collections that we provide).&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I’ve also created a member function called “Count” which returns the number of objects in my list (starting from the current node) and another member function called “Item” which returns me a reference to a specific object in the list, as indexed from the current node.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The code will compile and it will “work.”&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But, oh!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;It has &lt;B style="mso-bidi-font-weight: normal"&gt;so many&lt;/B&gt; hidden costs, and if the definition of MyLameObject exists in an assembly for which I don’t have the source code, I might not even realize it!&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;First, let’s look at button click handler.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;It’s calling Count() on every single iteration, and there will be a number of iterations equal to the value returned from Count().&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Count(), in turn, walks the entire list every time it’s called.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;So, that means that if my list contains 1000 items, that means that I’ll be referencing a MyLameObject &lt;I style="mso-bidi-font-style: normal"&gt;one million times&lt;/I&gt;!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;(This is what they refer to as an “O(n&lt;SUP&gt;2&lt;/SUP&gt;) problem” in computer science classes.)&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;But wait, it gets worse:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;S&gt;the code for Item() calls Count() also on each iteration to verify that the index is not out of bounds – that brings us up to a count of 1001000 MyLameObject references&lt;/S&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Edit&lt;/B&gt;:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As noted above, that isn’t true for VB, though it would be for many other languages&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;And, of course, Item() itself needs to walk the list to actual get to the desired item, on every iteration – that adds 500500 more object hits (using the n(n+1)/2 formula) , for a grand total of &lt;S&gt;1501500&lt;/S&gt; 1500500 object hits. And all that just to concatenate 1000 strings!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;That, I fear, is going to slow down my code’s performance somewhat.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now, of course I could add code to get track of values for Count(), and that would reduce my cost to a third of what it was.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I could use some clever hashing algorithm to more easily get to the items while still being able to use method calls.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;I could enumerate the list myself instead of relying on “Count” or on “Item,” and that would really cut my costs down dramatically.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Or, best of all, I could avoid reinventing the wheel and using the classes that VB.NET already supplies for me, since we do our best to optimize them.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;But that’s not the point that I’m trying to make here.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;The point is, whenever you call a function, &lt;I style="mso-bidi-font-style: normal"&gt;you are at its mercy performance-wise&lt;/I&gt; – you are stuck with whatever hidden costs it contains.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;You might not even be able to determine what these hidden costs are if you don’t own the code you’re calling, except by experimentation.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;And if you call that function iteratively, you’re just compounding the problem.&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Now, you can’t avoid making calls into code you don’t own – at some level, we all use libraries or assemblies that are handed to us.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;But you can be smart about how you use them&lt;S&gt;.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Consider *this* code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/S&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;S&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Text.&lt;SPAN style="COLOR: #2b91af"&gt;StringBuilder&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/S&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;S&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; count &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = MyList.Count&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/S&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;S&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; i &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Integer&lt;/SPAN&gt; = 0 &lt;SPAN style="COLOR: blue"&gt;To&lt;/SPAN&gt; count - 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/S&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;S&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s.Append(MyList(i))&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/S&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;S&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/S&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;S&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&lt;SPAN style="TEXT-DECORATION: none"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/S&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;S&gt;Now, I’m only calling Count() once, so I minimize the impact of its cost!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Or,&lt;/S&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt 0.5in; BACKGROUND: #d9d9d9; mso-background-themecolor: background1; mso-background-themeshade: 217" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Edit&lt;/B&gt;:&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;As above, this doesn’t actually make a difference in VB.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Of course, you still have the cost of “Count(),” whatever it may be.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;In this case, it’s just a property read; if it’s some home-grown collection or data repository, Count() (or it’s analog) could be a lot more costly.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;Consider this even &lt;I style="mso-bidi-font-style: normal"&gt;better&lt;/I&gt; example that you can use on collections that support IEnumerable (as all System.Collections types do):&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Dim&lt;/SPAN&gt; s &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; System.Text.&lt;SPAN style="COLOR: #2b91af"&gt;StringBuilder&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;For&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Each&lt;/SPAN&gt; data &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;String&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;In&lt;/SPAN&gt; MyList&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;s.Append(data)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 8pt"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Next&lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Yeah!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;I style="mso-bidi-font-style: normal"&gt;Now&lt;/I&gt; I’m firing on all cylinders!&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Now I don’t have to worry about indexing costs either – I’m just walking the list, collecting my strings in the fastest way possible.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Really, the only cost I have to deal with is the cost of actually appending the data (which is in fact why I’m using the highly-optimized StringBuilder class instead of just concatenating strings using a much more costly &lt;/FONT&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'"&gt;s &amp;amp;= data&lt;/SPAN&gt;&lt;/B&gt;&lt;FONT face=Calibri&gt; line).&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;So, rule of thumb: whenever calling any method, expect hidden costs (magnified if you’re in a loop) and work to minimize them.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Call the methods outside of the loop if they are providing data that will remain the same throughout the loop, such as a count, and avoid them altogether if there’s an alternative way to iterate through the data that doesn’t implicitly involve resetting your position.&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;Your customers will appreciate the time savings!&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3 face=Calibri&gt;‘Til next time,&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;--Matt--*&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9903925" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Matt+Gertz/default.aspx">Matt Gertz</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2005/default.aspx">VB2005</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Testing Events for Nothing/Null (Doug Rothaus)</title><link>http://blogs.msdn.com/vbteam/archive/2009/09/25/testing-events-for-nothing-null-doug-rothaus.aspx</link><pubDate>Fri, 25 Sep 2009 20:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9899600</guid><dc:creator>VBTeam</dc:creator><slash:comments>8</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9899600.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9899600</wfw:commentRss><description>&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;While helping some Windows API folks with some sample code this week, I stumbled upon...uh...I mean “carefully researched” an issue that you might find handy.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;You may be aware that the &lt;B style="mso-bidi-font-weight: normal"&gt;RaiseEvent&lt;/B&gt; statement automatically checks to verify if an event handler exists before raising the event. If the event is &lt;B style="mso-bidi-font-weight: normal"&gt;Nothing&lt;/B&gt;, then there’s no event handler and &lt;B style="mso-bidi-font-weight: normal"&gt;RaiseEvent&lt;/B&gt; terminates. If the event is not &lt;B style="mso-bidi-font-weight: normal"&gt;Nothing&lt;/B&gt;, then &lt;B style="mso-bidi-font-weight: normal"&gt;RaiseEvent&lt;/B&gt; triggers the event.&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;However, what if you want to follow a different code path if the event is &lt;B style="mso-bidi-font-weight: normal"&gt;Nothing&lt;/B&gt;? Unfortunately, the &lt;B style="mso-bidi-font-weight: normal"&gt;RaiseEvent&lt;/B&gt; statement doesn’t return a value that could indicate whether the event was fired. So, what’s a developer to do?&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;The answer? When the VB compiler sets up your event, it creates a private variable for the event in the form of &lt;I style="mso-bidi-font-style: normal"&gt;&amp;lt;event name&amp;gt;Event&lt;/I&gt;. So, if I set up an event named &lt;/FONT&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;TriggerMe&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;, the VB compiler creates an event variable named &lt;/FONT&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;TriggerMeEvent&lt;/SPAN&gt;&lt;FONT face=Calibri size=3&gt;.&amp;nbsp;You can test this variable for &lt;B style="mso-bidi-font-weight: normal"&gt;Nothing&lt;/B&gt;. It’s as simple as that! (Note: You won't see this variable using Intellisense, but you can find it when debugging or through reflection.)&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;FONT face=Calibri size=3&gt;Here’s a quick example:&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Public&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Event&lt;/SPAN&gt; SolutionFound &lt;SPAN style="COLOR: blue"&gt;As&lt;/SPAN&gt; EventHandler&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Private&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt; OnSolutionFound()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;If&lt;/SPAN&gt; SolutionFoundEvent &lt;SPAN style="COLOR: blue"&gt;IsNot&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Nothing&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Then&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;RaiseEvent&lt;/SPAN&gt; SolutionFound(&lt;SPAN style="COLOR: blue"&gt;Me&lt;/SPAN&gt;, &lt;SPAN style="COLOR: blue"&gt;New&lt;/SPAN&gt; EventArgs())&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;Else&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: green"&gt;' No event handler has been set.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;MsgBox(&lt;SPAN style="COLOR: #a31515"&gt;"There is no event handler. That makes me sad."&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;If&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;End&lt;/SPAN&gt; &lt;SPAN style="COLOR: blue"&gt;Sub&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9899600" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2008/default.aspx">VB2008</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Doug+Rothaus/default.aspx">Doug Rothaus</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Properties vs Fields – Why Does it Matter? (Jonathan Aneja)</title><link>http://blogs.msdn.com/vbteam/archive/2009/09/04/properties-vs-fields-why-does-it-matter-jonathan-aneja.aspx</link><pubDate>Sat, 05 Sep 2009 00:01:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9891610</guid><dc:creator>VBTeam</dc:creator><slash:comments>18</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9891610.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9891610</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;The other day I got an email from a developer asking an interesting question about VB10’s &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd293589(VS.100).aspx"&gt;&lt;font size="3" face="Calibri"&gt;Auto-implemented Properties&lt;/font&gt;&lt;/a&gt;&lt;font size="3" face="Calibri"&gt; feature.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;&lt;em&gt;“I am, however, somewhat confused regarding the properties feature you mentioned - i.e. turning 11 lines of get/set/backing variable into one line. Wouldn't this be exactly the same as the existing functionality of creating a public variable? I see no benefit for using a property in this case, except perhaps for the sake of what some would consider best practice.”&lt;/em&gt; &lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;i&gt;&lt;/i&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;On the surface there doesn’t seem to be a big difference between this:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Consola"&gt;&lt;font color="#0000ff"&gt;Public Property&lt;/font&gt; Name() &lt;font color="#0000ff"&gt;As String&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;And this:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Consola"&gt;&lt;font color="#0000ff"&gt;Public &lt;/font&gt;Name() &lt;font color="#0000ff"&gt;As String&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3"&gt;&lt;font face="Calibri"&gt;Clearly both will expose an object’s state to the outside world, and can be read/modified using the exact same syntax. Which then begs the question&lt;i&gt;, why would I ever use a property if I have no special logic in the Getter/Setter?&lt;/i&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;Let’s consider some reasons: &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font size="4" face="Calibri"&gt;1. Fields can’t be used in Interfaces&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/PropertiesvsFieldsWhyDoesitMatterJonatha_C547/clip_image002_2.jpg"&gt;&lt;font size="3" face="Calibri"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/PropertiesvsFieldsWhyDoesitMatterJonatha_C547/clip_image002_thumb.jpg" width="473" height="83" /&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;You can’t enforce the existence of a field in an object’s public contract through an interface. For properties though it works fine.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="4"&gt;&lt;font face="Calibri"&gt;&lt;b&gt;2. &lt;/b&gt;&lt;b&gt;Validation&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;While your application currently may not require any validation logic to set a particular value, changing business requirements may require inserting this logic later. At that point changing a field to a property is a breaking change for consumers of your API. (For example if someone was inspecting your class via reflection).&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="4"&gt;&lt;font face="Calibri"&gt;&lt;b&gt;3. &lt;/b&gt;&lt;b&gt;Binary Serialization&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;Changing a field to a property is a breaking change if you’re using binary serialization. Incidentally, this is one of the reasons VB10’s auto-implemented properties have a “bindable” backing field (i.e. you can express the name of the backing field in code) – that way, if you change an auto-implemented property to an expanded property, you can still maintain serialization compatibility by keeping the backing field name the same (in C# you’re forced to change it because it generates backing fields with unbindable names).&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="4"&gt;&lt;font face="Calibri"&gt;&lt;b&gt;4. &lt;/b&gt;&lt;b&gt;A lot of the .NET databinding infrastructure binds to properties but not fields&lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;I’ve heard arguments on both sides as to whether or not that’s a good thing, but the reality is that’s the way it works right now.&lt;/font&gt;&lt;/p&gt; &lt;b&gt;&lt;/b&gt;  &lt;p&gt;&lt;font size="4"&gt;&lt;font face="Calibri"&gt;&lt;b&gt;5. &lt;/b&gt;&lt;b&gt;Exposing a public field is an &lt;/b&gt;&lt;/font&gt;&lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms182141(VS.80).aspx"&gt;&lt;b&gt;&lt;font size="4" face="Calibri"&gt;FxCop violation&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;For many of the reasons listed above :)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;One argument I’ve heard for using fields over properties is that “fields are faster”, but for trivial properties that’s actually not true, as the CLR’s Just-In-Time (JIT) compiler will inline the property access and generate code that’s as efficient as accessing a field directly.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="3" face="Calibri"&gt;For these reasons and more, in most cases you’re better off using a property rather than exposing a public field. Thankfully &lt;a href="http://code.msdn.microsoft.com/vbfuture/Release/ProjectReleases.aspx?ReleaseId=1699"&gt;VB10&lt;/a&gt; will make this a lot easier :)&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9891610" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Jonathan+Aneja/default.aspx">Jonathan Aneja</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>TechEd Video: Future Directions for Visual Basic, by Anders Hejlsberg and Jonathan Aneja</title><link>http://blogs.msdn.com/vbteam/archive/2009/06/20/future-directions-for-visual-basic-by-anders-hejlsberg-and-jonathan-aneja.aspx</link><pubDate>Sat, 20 Jun 2009 18:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9791811</guid><dc:creator>VBTeam</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9791811.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9791811</wfw:commentRss><description>&lt;P&gt;As part of the new &lt;A href="http://channel9.msdn.com/posts/Charles/Luca-Bolognese-C-and-VBNET-Co-Evolution-The-Twain-Shall-Meet/" mce_href="http://channel9.msdn.com/posts/Charles/Luca-Bolognese-C-and-VBNET-Co-Evolution-The-Twain-Shall-Meet/"&gt;VB/C# co-evolution strategy&lt;/A&gt;, Visual Studio Technical Fellow Anders Hejlsberg has broadened his role. In addition to being Chief Architect for C#, he now sets the direction for both the VB.NET and C# languages. &lt;/P&gt;
&lt;P&gt;At TechEd, Anders participated in both the VB.NET and C# language presentations. In watching these sessions, you can see that the future trends and directions for the VB.NET and C# languages are now the same.&lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;&lt;A href="http://www.msteched.com/online/view.aspx?tid=1d3d650b-a6b3-4c98-9240-571866969b89" mce_href="http://www.msteched.com/online/view.aspx?tid=1d3d650b-a6b3-4c98-9240-571866969b89"&gt;TechEd NA 2009 Session Video: "Future Directions for Visual Basic" by Anders Hejlsberg and Jonathan Aneja&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;In this talk, we discuss the future direction of the Visual Basic language both in the near and long term. Exciting features from the next release are demonstrated and discussed, including extensions to LINQ support, syntax simplifications, and improvements to the IDE. Larger trends that are likely to deeply influence the direction of the language are also covered, including dynamic binding, meta-programming, and scripting. Finally, we discuss how all these tie together into the roadmap for Visual Basic going forward.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.msteched.com/online/view.aspx?tid=1d3d650b-a6b3-4c98-9240-571866969b89" mce_href="http://www.msteched.com/online/view.aspx?tid=1d3d650b-a6b3-4c98-9240-571866969b89"&gt;&lt;IMG style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=249 alt=image src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/FutureDirectionsforVisualBasicbyAndersHe_4FD/image_3.png" width=382 border=0 mce_src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/FutureDirectionsforVisualBasicbyAndersHe_4FD/image_3.png"&gt;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The C# TechEd US video is not publicly available. For the corresponding C# presentation, please watch the following from PDC:&lt;/P&gt;
&lt;P&gt;&lt;FONT size=4&gt;&lt;A href="http://channel9.msdn.com/pdc2008/TL16/" mce_href="http://channel9.msdn.com/pdc2008/TL16/"&gt;PDC 2008 Session Video: "The Future of C#" by Anders Hejlsberg&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;In this talk Microsoft Technical fellow and C# Chief Architect Anders Hejlsberg outlines the future of C#. He describes the many forces that influence and shape the future of programming languages and explain how they fit into C#.&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://channel9.msdn.com/pdc2008/TL16/" mce_href="http://channel9.msdn.com/pdc2008/TL16/"&gt;&lt;IMG style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=248 alt=image src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/FutureDirectionsforVisualBasicbyAndersHe_4FD/image5_3.png" width=328 border=0 mce_src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/FutureDirectionsforVisualBasicbyAndersHe_4FD/image5_3.png"&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9791811" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Lisa+Feigenbaum/default.aspx">Lisa Feigenbaum</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Jonathan+Aneja/default.aspx">Jonathan Aneja</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Anders+Hejlsberg/default.aspx">Anders Hejlsberg</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/TechEd2009/default.aspx">TechEd2009</category></item><item><title>Implicit Line Continuation (Kathleen McGrath)</title><link>http://blogs.msdn.com/vbteam/archive/2009/06/19/implicit-line-continuation-kathleen-mcgrath.aspx</link><pubDate>Fri, 19 Jun 2009 23:32:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9792064</guid><dc:creator>VBTeam</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9792064.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9792064</wfw:commentRss><description>&lt;p&gt;In the second part of my interview with Doug Rothaus, he describes the new implicit line continuation feature in Visual Basic 2010. Learn about the most common scenarios that no longer require the underscore character (_) in the topic, &lt;a href="http://msdn.microsoft.com/en-us/library/865x40k4(VS.100).aspx" target="_blank"&gt;Statements in Visual Basic&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;See the &lt;a href="http://channel9.msdn.com/posts/kmcgrath/Implicit-Line-Continuation-in-Visual-Basic-2010/" target="_blank"&gt;Video: implicit Line Continuation&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/kmcgrath/Implicit-Line-Continuation-in-Visual-Basic-2010/" target="_blank"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/ImplicitLineContinuationKathleenMcGrath_D896/image_3.png" width="365" height="279" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;--Kathleen McGrath    &lt;br /&gt;&lt;a href="http://blogs.msdn.com/kathleen"&gt;http://blogs.msdn.com/kathleen&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9792064" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Kathleen+McGrath/default.aspx">Kathleen McGrath</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Doug+Rothaus/default.aspx">Doug Rothaus</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Auto-Implemented Properties (Kathleen McGrath)</title><link>http://blogs.msdn.com/vbteam/archive/2009/06/12/auto-implemented-properties-kathleen-mcgrath.aspx</link><pubDate>Sat, 13 Jun 2009 00:46:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9739570</guid><dc:creator>VBTeam</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9739570.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9739570</wfw:commentRss><description>&lt;p&gt;In this interview, Doug Rothaus, a programming writer on the Visual Studio User Education team, describes the auto-implemented properties in Visual Basic 2010. He also demonstrates some of the code examples in his Help topic: &lt;a href="http://msdn.microsoft.com/en-us/library/dd293589(VS.100).aspx"&gt;Auto-Implemented Properties&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;See the &lt;a href="http://channel9.msdn.com/posts/kmcgrath/Auto-Implemented-Properties-in-Visual-Basic-2010/" target="_blank"&gt;Video: Auto-Implement Properties&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://channel9.msdn.com/posts/kmcgrath/Auto-Implemented-Properties-in-Visual-Basic-2010/" target="_blank"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/AutoImplementedPropertiesVideowithDougRo_AE46/image_6.png" width="317" height="240" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;--Kathleen&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9739570" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Kathleen+McGrath/default.aspx">Kathleen McGrath</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/Doug+Rothaus/default.aspx">Doug Rothaus</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>Try Out Dotfuscator in VS 2010 Beta 1!</title><link>http://blogs.msdn.com/vbteam/archive/2009/06/10/try-out-dotfuscator-in-vs-2010-beta-1.aspx</link><pubDate>Thu, 11 Jun 2009 04:03:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9725483</guid><dc:creator>VBTeam</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9725483.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9725483</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt;The team at PreEmptive Solutions recently posted a great blog article that walks through all the latest features in VS 2010's Dotfuscator Software Services - Community Edition (previously known as Dotfuscator CE). Browse through the article to learn what's new, or &lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" target="_blank"&gt;download the beta&lt;/a&gt; to follow along in the IDE.&lt;/p&gt;  &lt;h4&gt;&lt;a href="http://blogs.preemptive.com/post/Whate28099s-new-with-Dotfuscator-in-Visual-Studio-2010-Beta-1.aspx"&gt;What's New with Dotfuscator in Visual Studio 2010 Beta 1 &lt;/a&gt;by Bill Leach&lt;/h4&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9725483" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Lisa+Feigenbaum/default.aspx">Lisa Feigenbaum</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item><item><title>VS2010 Beta1 Extensibility News (Lisa Feigenbaum)</title><link>http://blogs.msdn.com/vbteam/archive/2009/06/10/vs2010-beta1-extensibility-news-lisa-feigenbaum.aspx</link><pubDate>Wed, 10 Jun 2009 19:47:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9724588</guid><dc:creator>VBTeam</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/vbteam/comments/9724588.aspx</comments><wfw:commentRss>http://blogs.msdn.com/vbteam/commentrss.aspx?PostID=9724588</wfw:commentRss><description>&lt;p&gt;I recently received this letter from the Visual Studio Extensibility team, that I thought would be interesting to readers of this blog. Whether you're building Visual Studio extensions or downloading them from others, there's news here for you.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-weight: bold"&gt;News from the Visual Studio Extensibility team&amp;#8230;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&amp;#160;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Are you building new tools to simplify your life or change the way people work?&amp;#160; Check out the opportunities to create innovative extensions for Visual Studio 2010.&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&amp;#160;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 27.35pt"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Examples of cool things you can do:&lt;span style="color: #1f497d"&gt;         &lt;p&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 11pt; color: #1f497d; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;         &lt;p&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in; text-indent: -0.25in; mso-list: l1 level1 lfo1; tab-stops: list 1.75in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-bidi-font-weight: bold; mso-fareast-font-family: symbol; mso-bidi-font-style: italic"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Overlay rich metadata on top of the editor to bring new information to your fingertips&lt;b&gt;&lt;i&gt;         &lt;p&gt;&lt;/p&gt;       &lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in; text-indent: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list 1.75in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Develop new project templates to accelerate your work (examples: New Project Dialog)     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in; text-indent: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list 1.75in"&gt;&lt;span style="color: #1f497d; font-family: symbol; mso-bidi-font-family: symbol; mso-bidi-font-weight: bold; mso-fareast-font-family: symbol; mso-bidi-font-style: italic"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Create innovative user interface elements using the WPF Shell&lt;b&gt;&lt;i&gt;&lt;span style="color: #1f497d"&gt;           &lt;p&gt;&lt;/p&gt;         &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in; text-indent: -0.25in; mso-list: l1 level1 lfo1; tab-stops: list 1.75in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Upload your extension to the Visual Studio Gallery (&lt;a href="http://visualstudiogallery.com"&gt;&lt;span style="color: blue"&gt;http://visualstudiogallery.com&lt;/span&gt;&lt;/a&gt;) to find it in the Extension Manager      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;     &lt;p&gt;&amp;#160;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Other things you should know:       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in; text-indent: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list 1.75in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;With v2 of the &lt;b&gt;Visual Studio Gallery&lt;/b&gt; that went live on 5/14, you can use the Extension Manager to find products from the ecosystem from within Visual Studio      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; *(with Beta1, the Extension Manager will only surface extensions posted to the Gallery in the VSIX file format; Beta2 will include the MSI format)     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in; text-indent: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list 1.75in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;We just released the new SDK along with the new Shell redistributables&lt;/span&gt;&lt;/b&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;, &lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;look for them at the dev center: &lt;a href="http://msdn.com/vsx"&gt;&lt;span style="color: blue"&gt;http://msdn.com/vsx&lt;/span&gt;&lt;/a&gt;      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in; text-indent: -0.25in; mso-list: l2 level1 lfo2; tab-stops: list 1.75in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;If you&amp;#8217;re developing extensions for VS 2010, you&amp;#8217;ll want to stay tuned to the dev center for more information     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 1.25in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;     &lt;p&gt;&amp;#160;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;span style="mso-tab-count: 3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;Fun things to help you get started &amp;#8211; these can be found in the Extension Manager (Tools&amp;gt;Extension Manager): search for Editor Extensions        &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;         &lt;p&gt;&amp;#160;&lt;/p&gt;       &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;div align="center"&gt;   &lt;table class="MsoNormalTable" style="margin-left: -28.25pt; width: 65.54%; border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 0in 0in 0in" cellspacing="0" cellpadding="0" width="65%" border="0"&gt;&lt;tbody&gt;       &lt;tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: black 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 100%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="100%" colspan="2"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-style: italic"&gt;DemoDashboard Sample:                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 1"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 48.8%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="48%"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;               &lt;p&gt;&amp;#160;&lt;/p&gt;             &lt;/span&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;The DemoDashboard sample is a WPF &amp;#8220;dashboard&amp;#8221; designed for folks presenting demos in VS2010 to get real-time audience feedback via Twitter. Use this sample to give presentations, build your own widgets, etc.&amp;#160; The wiki on the CodePlex site will give you all the info you need to get started. &lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;You can share the feedback you get with your followers on Twitter.               &lt;p&gt;&lt;/p&gt;             &lt;/span&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;               &lt;p&gt;&amp;#160;&lt;/p&gt;             &lt;/span&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;get it:&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;Tools&amp;gt;Extension Manager                  &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;or from the Gallery: &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/7f790ec9-a267-4a22-aa65-dc6f7af34f24"&gt;here&lt;/a&gt;                  &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;source: http://demodashboard.codeplex.com                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"&gt;                 &lt;p&gt;&amp;#160;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: medium none; width: 51.2%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="51%"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image002_4.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="148" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image002_thumb_1.jpg" width="244" border="0" v:shapes="Picture_x0020_2" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt"&gt;                   &lt;p&gt;&lt;/p&gt;                 &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 2"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 100%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="100%" colspan="2"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;RegEx Editor Sample                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="height: 227.6pt; mso-yfti-irow: 3"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 48.8%; padding-top: 0in; border-bottom: black 1pt solid; height: 227.6pt" valign="top" width="48%"&gt;           &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;span style="font-size: 10pt; font-family: " trebuchet ms","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-bidi"&gt;               &lt;p&gt;&amp;#160;&lt;/p&gt;             &lt;/span&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;This sample was built to ease the your pain when working with regular expressions.&amp;#160; It shows re-hosting of the editor in a window and provides a nice starting point for similar projects.             &lt;p&gt;&lt;/p&gt;           &lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;             &lt;p&gt;&amp;#160;&lt;/p&gt;           &lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;get it:&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;Tools&amp;gt;Extension Manager                  &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;or from the Gallery: &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/55c24bf1-2636-4f94-831d-28db8505ce00"&gt;here&lt;/a&gt;                  &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;source: http://editorsamples.codeplex.com                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;                 &lt;p&gt;&amp;#160;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: medium none; width: 51.2%; padding-top: 0in; border-bottom: black 1pt solid; height: 227.6pt" valign="top" width="51%"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image004_4.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="181" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image004_thumb_1.jpg" width="244" border="0" v:shapes="Picture_x0020_3" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt"&gt;                   &lt;p&gt;&lt;/p&gt;                 &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 4"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 100%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="100%" colspan="2"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-style: italic"&gt;Custom Intellisense Sample&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"&gt;                   &lt;p&gt;&lt;/p&gt;                 &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="height: 242pt; mso-yfti-irow: 5"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 48.8%; padding-top: 0in; border-bottom: black 1pt solid; height: 242pt" valign="top" width="48%"&gt;           &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;span style="font-size: 10pt; font-family: " trebuchet ms","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-bidi"&gt;               &lt;p&gt;&amp;#160;&lt;/p&gt;             &lt;/span&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;This sample provides a custom WPF-based UI for Intellisense -- with databinding and other cool features.&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;You might want to use it as-is, you might want to personalize it, you might want to build new features for it &amp;#8211;&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;the choice is yours.              &lt;p&gt;&lt;/p&gt;           &lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;             &lt;p&gt;&amp;#160;&lt;/p&gt;           &lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;get it: Tools&amp;gt;Extension Manager                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;or from the Gallery: &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/ca201b20-8100-4f9a-a653-a20ae308e82e"&gt;here&lt;/a&gt;                  &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;source: http://editorsamples.codeplex.com                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;                 &lt;p&gt;&amp;#160;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;             &lt;p&gt;&amp;#160;&lt;/p&gt;           &lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;             &lt;p&gt;&amp;#160;&lt;/p&gt;           &lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: medium none; width: 51.2%; padding-top: 0in; border-bottom: black 1pt solid; height: 242pt" valign="top" width="51%"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image006_4.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="189" alt="clip_image006" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image006_thumb_1.jpg" width="244" border="0" v:shapes="Picture_x0020_4" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt"&gt;                   &lt;p&gt;&lt;/p&gt;                 &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 6"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 48.8%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="48%"&gt;&lt;/td&gt;          &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: medium none; width: 51.2%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="51%"&gt;&lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 7"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 100%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="100%" colspan="2"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-style: italic"&gt;Image Insertion Sample&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"&gt;                   &lt;p&gt;&lt;/p&gt;                 &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 8; mso-yfti-lastrow: yes"&gt;         &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: black 1pt solid; width: 48.8%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="48%"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt"&gt;                   &lt;p&gt;&amp;#160;&lt;/p&gt;                 &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;This sample is all about visualizing resources inline, it provides some nice transparency effects when you&amp;#8217;re dragging an image from the solution explorer, and will automatically resize text to fit the image.               &lt;p&gt;&lt;/p&gt;             &lt;/span&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;               &lt;p&gt;&amp;#160;&lt;/p&gt;             &lt;/span&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;get it: Tools&amp;gt;Extension Manager                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoNormal" style="margin: 6pt 0in; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; color: #c00000; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;or from the Gallery: &lt;a href="http://visualstudiogallery.msdn.microsoft.com/en-us/793d16d0-235a-439a-91df-4ce7c721df12"&gt;here&lt;/a&gt;                  &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;source: http://editorsamples.codeplex.com                 &lt;p&gt;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;            &lt;p class="MsoListParagraph" style="margin: 6pt 0in 0pt; text-align: center" align="center"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="color: #c00000"&gt;                 &lt;p&gt;&amp;#160;&lt;/p&gt;               &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-right: black 1pt solid; padding-right: 5.4pt; border-top: medium none; padding-left: 5.4pt; padding-bottom: 0in; border-left: medium none; width: 51.2%; padding-top: 0in; border-bottom: black 1pt solid" valign="top" width="51%"&gt;           &lt;p class="MsoNormal" style="margin: 6pt 0in"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;i style="mso-bidi-font-style: normal"&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt; mso-no-proof: yes"&gt;&lt;a href="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image008_4.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="175" alt="clip_image008" src="http://blogs.msdn.com/blogfiles/vbteam/WindowsLiveWriter/VS2010Beta1ExtensibilityNewsLisaFeigenba_8963/clip_image008_thumb_1.jpg" width="244" border="0" v:shapes="Picture_x0020_5" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'; mso-bidi-font-size: 10.0pt"&gt;                   &lt;p&gt;&lt;/p&gt;                 &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/div&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;         &lt;p&gt;&amp;#160;&lt;/p&gt;       &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;i&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;         &lt;p&gt;&lt;/p&gt;       &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;FAQ:       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&amp;#160;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; What is the Extension Manager and how do I find it?        &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;The Extension Manager in Visual Studio enables developers to discover Visual Studio Extensions from within the product itself. It consumes data directly from the Visual Studio Gallery, giving developers direct access to partner and community products that extend and enhance Visual Studio.&amp;#160; If you have a free or free trial version of your product hosted on the Visual Studio Gallery, a developer will be able to download and install that product directly from within the IDE.&amp;#160; (In Beta1, the in-product experience will show only extensions uploaded as a VSIX.&amp;#160; In Beta 2 we will expand the in-product experience to also include extensions uploaded as MSI and reference links to other download sites.)     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;The Extension Manager enables a developer to install, upgrade, uninstall, enable, and disable extensions, making it easier to manage a portfolio of extensions.&amp;#160; &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;To find the Extension Manager:&amp;#160; Tools&amp;gt;Extension Manager.     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&amp;#160; &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; So this means the Visual Studio Gallery can now host downloads?       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Yes, we&amp;#8217;re excited to announce that the Visual Studio Gallery can now host your downloads.&amp;#160; Keep in mind that at this time the gallery does not include a commerce framework so we recommend creating a free or free trial version of your product that can be hosted on the Visual Studio Gallery.&amp;#160; Of course we still support reference links for users who prefer to host their own downloads.     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 27pt"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;     &lt;p&gt;&amp;#160;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; What else is new @ the Visual Studio Gallery?       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Thanks to some great work by the MSDN team we&amp;#8217;ve moved the Visual Studio Gallery to be part of MSDN.&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;Some of the benefits:&lt;span style="color: #1f497d"&gt;       &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.95in; vertical-align: middle; text-indent: -0.25in; mso-list: l0 level2 lfo3; tab-stops: list 1.0in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;The new navigation model supports all types of Visual Studio Extensions and has sections for Tools, Controls, and Templates &lt;/span&gt;&lt;span style="font-size: 12pt; font-family: " times new roman","serif""&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.95in; vertical-align: middle; text-indent: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;The integration with MSDN now gives users a chance to take advantage of a shared profile across all MSDN properties.&amp;#160; Contributing to the gallery can enhance your MSDN reputation giving high quality contributors the recognition they deserve.&lt;/span&gt;&lt;span style="font-size: 12pt; font-family: " times new roman","serif""&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.95in; vertical-align: middle; text-indent: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Visual Studio Gallery contributions offer an optional discussion board to separate your reviews and give contributors an opportunity to post updates, respond to feedback, &amp;amp; discuss bugs.&lt;/span&gt;&lt;span style="font-size: 12pt; font-family: " times new roman","serif""&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.95in; vertical-align: middle; text-indent: -0.25in; mso-list: l0 level1 lfo3; tab-stops: list .5in"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol; mso-bidi-font-size: 12.0pt"&gt;&lt;span style="mso-list: ignore"&gt;&amp;#183;&lt;span style="font: 7pt " times new roman""&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;All entries include a usage chart to give contributors a sense of which of their products are getting the most traffic on the Visual Studio Gallery.&lt;/span&gt;&lt;span style="font-size: 12pt; font-family: " times new roman","serif""&gt;     &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;       &lt;p&gt;&amp;#160;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; What&amp;#8217;s the deal with the VSIX file format I&amp;#8217;ve heard about?&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left: 0.5in"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;Both the new Visual Studio Gallery and the Extension Manager work with .VSIX files, which is a new deployment model for extensions, similar to a renamed .ZIP file.&amp;#160; This transition provides Visual Studio users a new low-overhead, reliable way to deploy Visual Studio Extensions. There&amp;#8217;s tooling available to help you with this, and you can find instructions and other helpful tips at the Visual Studio Extensibility Dev Center:&amp;#160; &lt;a href="http://msdn.com/vsx"&gt;&lt;span style="color: blue"&gt;http://msdn.com/vsx&lt;/span&gt;&lt;/a&gt;.      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&amp;#160;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;Questions?        &lt;p&gt;&lt;/p&gt;     &lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-size: 11pt; font-family: " calibri","sans-serif"; mso-bidi-font-family: 'Times New Roman'"&gt;&lt;span style="mso-tab-count: 1"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;Email &lt;a href="mailto:catherine.crim@microsoft.com"&gt;catherine.crim@microsoft.com&lt;/a&gt;      &lt;p&gt;&lt;/p&gt;   &lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9724588" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/vbteam/archive/tags/Lisa+Feigenbaum/default.aspx">Lisa Feigenbaum</category><category domain="http://blogs.msdn.com/vbteam/archive/tags/VB2010/default.aspx">VB2010</category></item></channel></rss>