<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>OOP - There It Is - .NET</title>
    <link>http://www.vpsw.com/blogbaby/</link>
    <description>A Very Practical Blog</description>
    <language>en-us</language>
    <copyright>Dean Fiala</copyright>
    <lastBuildDate>Wed, 11 Jun 2008 03:24:01 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>dfiala@vpsw.com</managingEditor>
    <webMaster>dfiala@vpsw.com</webMaster>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=5ebf2926-8003-4c16-b328-8e91755317b0</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,5ebf2926-8003-4c16-b328-8e91755317b0.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,5ebf2926-8003-4c16-b328-8e91755317b0.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=5ebf2926-8003-4c16-b328-8e91755317b0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The Resharper cult members already know this, but for those who haven't joined yet,
version <a href="http://www.jetbrains.com/resharper/download/">4.0 released today</a> with
VS 2008 support -- huzzah,  huzzah.  No longer able to resist the chanting
and promises of eternal coolness I donned my robe and installed my free copy.
</p>
        <p>
I clearly should have joined sooner.  Resharper has already changed my life. 
First it pointed that I had redundant overrides  in the control I was working
on, which I had really meant to delete. 
</p>
        <p>
Then it reminded me about the new <a href="http://msdn.microsoft.com/en-us/library/bb384061.aspx">implicit
type declaration</a> keyword var, so this...
</p>
        <blockquote>
          <p>
            <font face="Courier New" color="#0000ff">XmlDocument SomeDoc = new XmlDocument();</font>
          </p>
        </blockquote>
        <p>
becomes...
</p>
        <blockquote>
          <p>
            <font face="Courier New" color="#0000ff">var SomeDoc = new XmlDocument();</font>
          </p>
        </blockquote>
        <p>
Granted, that's not too exciting, but if your type declaration is something like...
</p>
        <blockquote>
          <font face="Courier New" color="#0000ff">Dictionary&lt;SomeStrangeType,ANamespace.AnotherLongType&gt;
SomeDictionary = new Dictionary&lt;SomeStrangeType,ANamespace.AnotherLongType&gt;();</font>
        </blockquote>
        <p>
with var it becomes...
</p>
        <blockquote>
          <p>
            <font face="Courier New" color="#0000ff">var SomeDictionary = new Dictionary&lt;SomeStrangeType,ANamespace.AnotherLongType&gt;();</font>
          </p>
        </blockquote>
        <p>
Then Resharper pointed out something I didn't realize was available in C#, the <a href="http://msdn.microsoft.com/en-us/library/bb384062.aspx">object
intializer</a>?? VB.NET has long had something similar with the <a href="http://msdn.microsoft.com/en-us/library/wc500chb.aspx">With
statement</a> (now with <a href="http://msdn.microsoft.com/en-us/library/bb385125.aspx">object
initializer goodness</a> too).  What's nice about this is that it saves repeating
the instance name in front of the properties.  So this...
</p>
        <blockquote>
          <p>
            <font face="Courier New" color="#0000ff">var MenuBinding = new MenuItemBinding(); 
<br />
MenuBinding.DataMember = MenuItemElementName; 
<br />
MenuBinding.TextField = DisplayTextAttribute; 
<br />
MenuBinding.NavigateUrlField = NavigationUrlAttribute; 
<br />
MenuBinding.Depth = Depth;</font>
          </p>
        </blockquote>
        <p>
becomes...
</p>
        <blockquote>
          <p>
            <font face="Courier New" color="#0000ff">var MenuBinding = new MenuItemBinding 
<br />
  { 
<br />
     DataMember = MenuItemElementName, 
<br />
     TextField = DisplayTextAttribute, 
<br />
     NavigateUrlField = NavigationUrlAttribute, 
<br />
     Depth = Depth 
<br />
  };</font>
          </p>
        </blockquote>
        <p>
I was staring at this new construct when I realized that -- it shouldn't work. The
project I was working on was a Framework 2.0 project and these things were in 3.0
syntax.  But the darn thing compiles and works.  Not even a single warning. 
WTF?  It turns out that since 3.0 and 3.5 are based on 2.0, these are simply
compiler tricks -- there is nothing fundamentally different about the types. 
Here's a <a href="http://weblogs.asp.net/shahar/archive/2008/01/23/use-c-3-features-from-c-2-and-net-2-0-code.aspx">blog
post</a> that explores in more detail what is happening under the covers.
</p>
        <p>
Not bad for 15 minutes of tooling around.  Guess I am an official member. Where's
the Koolaid?
</p>
        <img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=5ebf2926-8003-4c16-b328-8e91755317b0" />
      </body>
      <title>Sharpening Knives</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,5ebf2926-8003-4c16-b328-8e91755317b0.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,5ebf2926-8003-4c16-b328-8e91755317b0.aspx</link>
      <pubDate>Wed, 11 Jun 2008 03:24:01 GMT</pubDate>
      <description>&lt;p&gt;
The Resharper cult members already know this, but for those who haven't joined yet,
version &lt;a href="http://www.jetbrains.com/resharper/download/"&gt;4.0 released today&lt;/a&gt; with
VS 2008 support -- huzzah,&amp;#160; huzzah.&amp;#160; No longer able to resist the chanting
and promises of eternal coolness I donned my robe and installed my free copy.
&lt;/p&gt;
&lt;p&gt;
I clearly should have joined sooner.&amp;#160; Resharper has already changed my life.&amp;#160;
First it pointed that I had redundant overrides&amp;#160; in the control I was working
on, which I had really meant to delete. 
&lt;/p&gt;
&lt;p&gt;
Then it reminded me about the new &lt;a href="http://msdn.microsoft.com/en-us/library/bb384061.aspx"&gt;implicit
type declaration&lt;/a&gt; keyword var, so this...
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" color="#0000ff"&gt;XmlDocument SomeDoc = new XmlDocument();&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
becomes...
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" color="#0000ff"&gt;var SomeDoc = new XmlDocument();&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Granted, that's not too exciting, but if your type declaration is something like...
&lt;/p&gt;
&lt;blockquote&gt;&lt;font face="Courier New" color="#0000ff"&gt;Dictionary&amp;lt;SomeStrangeType,ANamespace.AnotherLongType&amp;gt;
SomeDictionary = new Dictionary&amp;lt;SomeStrangeType,ANamespace.AnotherLongType&amp;gt;();&lt;/font&gt; &lt;/blockquote&gt; 
&lt;p&gt;
with var it becomes...
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" color="#0000ff"&gt;var SomeDictionary = new Dictionary&amp;lt;SomeStrangeType,ANamespace.AnotherLongType&amp;gt;();&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Then Resharper pointed out something I didn't realize was available in C#, the &lt;a href="http://msdn.microsoft.com/en-us/library/bb384062.aspx"&gt;object
intializer&lt;/a&gt;?? VB.NET has long had something similar with the &lt;a href="http://msdn.microsoft.com/en-us/library/wc500chb.aspx"&gt;With
statement&lt;/a&gt; (now with &lt;a href="http://msdn.microsoft.com/en-us/library/bb385125.aspx"&gt;object
initializer goodness&lt;/a&gt; too).&amp;#160; What's nice about this is that it saves repeating
the instance name in front of the properties.&amp;#160; So this...
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" color="#0000ff"&gt;var MenuBinding = new MenuItemBinding(); 
&lt;br /&gt;
MenuBinding.DataMember = MenuItemElementName; 
&lt;br /&gt;
MenuBinding.TextField = DisplayTextAttribute; 
&lt;br /&gt;
MenuBinding.NavigateUrlField = NavigationUrlAttribute; 
&lt;br /&gt;
MenuBinding.Depth = Depth;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
becomes...
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" color="#0000ff"&gt;var MenuBinding = new MenuItemBinding 
&lt;br /&gt;
&amp;#160; { 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160; DataMember = MenuItemElementName, 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160; TextField = DisplayTextAttribute, 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160; NavigateUrlField = NavigationUrlAttribute, 
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160; Depth = Depth 
&lt;br /&gt;
&amp;#160; };&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I was staring at this new construct when I realized that -- it shouldn't work. The
project I was working on was a Framework 2.0 project and these things were in 3.0
syntax.&amp;#160; But the darn thing compiles and works.&amp;#160; Not even a single warning.&amp;#160;
WTF?&amp;#160; It turns out that since 3.0 and 3.5 are based on 2.0, these are simply
compiler tricks -- there is nothing fundamentally different about the types.&amp;#160;
Here's a &lt;a href="http://weblogs.asp.net/shahar/archive/2008/01/23/use-c-3-features-from-c-2-and-net-2-0-code.aspx"&gt;blog
post&lt;/a&gt; that explores in more detail what is happening under the covers.
&lt;/p&gt;
&lt;p&gt;
Not bad for 15 minutes of tooling around.&amp;#160; Guess I am an official member. Where's
the Koolaid?
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=5ebf2926-8003-4c16-b328-8e91755317b0" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,5ebf2926-8003-4c16-b328-8e91755317b0.aspx</comments>
      <category>.NET</category>
      <category>2.0</category>
      <category>3.0</category>
      <category>3.5</category>
      <category>Resharper</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=cd94d8d1-fdda-4a14-8549-2f597a593660</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,cd94d8d1-fdda-4a14-8549-2f597a593660.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,cd94d8d1-fdda-4a14-8549-2f597a593660.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=cd94d8d1-fdda-4a14-8549-2f597a593660</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Nothing like a <a href="http://www.novacodecamp.org/">code
camp</a> to get jazzed about all the stuff I could be working on. It is like a revival
meeting; everything is new and exciting and possible.<br /><br />
I took in <a href="http://www.novacodecamp.org/CodeCamps/NoVaCodeCamp200801/Sessions/tabid/153/Default.aspx">sessions</a> about
making DotNetNuke modules and the new ASP.NET Dynamic Data extensions. Very interesting
stuff.  The Dynamic Data stuff appears to be a great way to bang out admin pages
with minimal effort.<br /><br />
I also presented my <a href="http://www.vpsw.com/down/PeertoPeerNetworkingWith3_5.ppt">little
talk</a> about the new <a href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.aspx">Peer-to-Peer
Networking</a> goodies in the .NET 3.5 framework.  This is stuff that's been
possible to do with the Windows API for a long time, but has finally been exposed
through the managed classes for access by mere mortals.  Here is yet <a href="http://www.vpsw.com/down/Chatty.zip">another
chat application</a> that demonstrates how it all works.<br /><br />
The real exciting namespace is its child the <a href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.collaboration.aspx">PeerToPeer.Collaboration</a> namespace. 
It is a framework for building p2p apps.  Didn't have the time to delve into
it fully, as it is only supported in Vista. But it did provide the first compelling
reason to upgrade, so I finally succumbed. 
<br /><br />
Just need to invent the 50 hour day to get to try out all the things I'd like to.<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=cd94d8d1-fdda-4a14-8549-2f597a593660" /></body>
      <title>Camping Out</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,cd94d8d1-fdda-4a14-8549-2f597a593660.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,cd94d8d1-fdda-4a14-8549-2f597a593660.aspx</link>
      <pubDate>Sun, 18 May 2008 01:30:07 GMT</pubDate>
      <description>Nothing like a &lt;a href="http://www.novacodecamp.org/"&gt;code camp&lt;/a&gt; to get jazzed
about all the stuff I could be working on. It is like a revival meeting; everything
is new and exciting and possible.&lt;br&gt;
&lt;br&gt;
I took in &lt;a href="http://www.novacodecamp.org/CodeCamps/NoVaCodeCamp200801/Sessions/tabid/153/Default.aspx"&gt;sessions&lt;/a&gt; about
making DotNetNuke modules and the new ASP.NET Dynamic Data extensions. Very interesting
stuff.&amp;nbsp; The Dynamic Data stuff appears to be a great way to bang out admin pages
with minimal effort.&lt;br&gt;
&lt;br&gt;
I also presented my &lt;a href="http://www.vpsw.com/down/PeertoPeerNetworkingWith3_5.ppt"&gt;little
talk&lt;/a&gt; about the new &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.aspx"&gt;Peer-to-Peer
Networking&lt;/a&gt; goodies in the .NET 3.5 framework.&amp;nbsp; This is stuff that's been
possible to do with the Windows API for a long time, but has finally been exposed
through the managed classes for access by mere mortals.&amp;nbsp; Here is yet &lt;a href="http://www.vpsw.com/down/Chatty.zip"&gt;another
chat application&lt;/a&gt; that demonstrates how it all works.&lt;br&gt;
&lt;br&gt;
The real exciting namespace is its child the &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.peertopeer.collaboration.aspx"&gt;PeerToPeer.Collaboration&lt;/a&gt; namespace.&amp;nbsp;
It is a framework for building p2p apps.&amp;nbsp; Didn't have the time to delve into
it fully, as it is only supported in Vista. But it did provide the first compelling
reason to upgrade, so I finally succumbed. 
&lt;br&gt;
&lt;br&gt;
Just need to invent the 50 hour day to get to try out all the things I'd like to.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=cd94d8d1-fdda-4a14-8549-2f597a593660" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,cd94d8d1-fdda-4a14-8549-2f597a593660.aspx</comments>
      <category>.NET</category>
      <category>3.5</category>
      <category>p2p</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=b187e79b-18a4-4edc-a0e8-61932ac53ae3</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,b187e79b-18a4-4edc-a0e8-61932ac53ae3.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,b187e79b-18a4-4edc-a0e8-61932ac53ae3.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=b187e79b-18a4-4edc-a0e8-61932ac53ae3</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">I went on vacation at the end of July and
returned in early August. Life restarted in fits and starts.  But somehow I neglected
to get this blog started again. Now that five months have passed, I think it is time
to begin again.  So without further ado...<br /><br />
Had a question on a forum today about how to access the top master page if you are
using nested master pages.  Seemed like a good time to break out some recursion.  
<br /><br /><blockquote><font color="#000080" face="Courier New">protected MasterPage UltimateMaster(Page
ThePage)</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">{</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      if
(ThePage.Master == null)</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      {</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">        
//no master</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">        
return null;</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      }</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      else</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      {</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">        
return UltimateMaster(ThePage.Master);</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      }</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">}</font><font color="#000080"><br /><br /><font face="Courier New">//this will call itself until it runs out of Master Pages</font><br /></font><font color="#000080" face="Courier New">protected MasterPage UltimateMaster(MasterPage
ThePage)</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">{</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      MasterPage
TheMaster;</font><font color="#000080"><br /><br /></font><font color="#000080" face="Courier New">      if
(ThePage.Master == null)</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      {</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">          
TheMaster = ThePage;</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      }</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      else</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      {</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">          
TheMaster = UltimateMaster(ThePage.Master);</font><font color="#000080"><br /><br /></font><font color="#000080" face="Courier New">      }</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">      return
TheMaster;</font><font color="#000080"><br /></font><font color="#000080" face="Courier New">}</font><br /></blockquote>I'd add these methods to a base web page class, so I can access them
from all my pages.  Then it is easy to access the ultimate master page at any
time...<br /><blockquote><font color="#000080" face="Courier New">MasterPage TheUltimateMaster
= UltimateMaster(this);</font><br /></blockquote>To access any custom properties or methods that have been exposed, the
master page needs to be cast to its strong type...<br /><blockquote><font color="#000080" face="Courier New">MyUltimateMasterPageType MyMaster
= (MyUltimateMasterPageType) TheUltimateMaster; </font><br /></blockquote>Then the ultimate master page is ready to be used...<br /><blockquote><font color="#000080" face="Courier New">MyMaster.AUsefulMethod("SomethingSomehting"); </font><br /></blockquote>I haven't had the occasion to use nested master pages, but I thought
I'd offer this as an early Christmas present to anyone who does.<br /><br />
Happy Holidays.  Merry Christmas!<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=b187e79b-18a4-4edc-a0e8-61932ac53ae3" /></body>
      <title>Where Oh Where Has My Little Blog Gone</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,b187e79b-18a4-4edc-a0e8-61932ac53ae3.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,b187e79b-18a4-4edc-a0e8-61932ac53ae3.aspx</link>
      <pubDate>Fri, 21 Dec 2007 02:15:38 GMT</pubDate>
      <description>I went on vacation at the end of July and returned in early August. Life restarted in fits and starts.&amp;nbsp; But somehow I neglected to get this blog started again. Now that five months have passed, I think it is time to begin again.&amp;nbsp; So without further ado...&lt;br&gt;
&lt;br&gt;
Had a question on a forum today about how to access the top master page if you are
using nested master pages.&amp;nbsp; Seemed like a good time to break out some recursion.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;protected MasterPage UltimateMaster(Page
ThePage)&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;{&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if
(ThePage.Master == null)&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
//no master&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return null;&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return UltimateMaster(ThePage.Master);&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;}&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;//this will call itself until it runs out of Master Pages&lt;/font&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;protected MasterPage UltimateMaster(MasterPage
ThePage)&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;{&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MasterPage
TheMaster;&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if
(ThePage.Master == null)&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
TheMaster = ThePage;&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
TheMaster = UltimateMaster(ThePage.Master);&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return
TheMaster;&lt;/font&gt;&lt;font color="#000080"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#000080" face="Courier New"&gt;}&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;I'd add these methods to a base web page class, so I can access them
from all my pages.&amp;nbsp; Then it is easy to access the ultimate master page at any
time...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;MasterPage TheUltimateMaster
= UltimateMaster(this);&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;To access any custom properties or methods that have been exposed, the
master page needs to be cast to its strong type...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;MyUltimateMasterPageType MyMaster
= (MyUltimateMasterPageType) TheUltimateMaster; &lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;Then the ultimate master page is ready to be used...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;MyMaster.AUsefulMethod("SomethingSomehting"); &lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;I haven't had the occasion to use nested master pages, but I thought
I'd offer this as an early Christmas present to anyone who does.&lt;br&gt;
&lt;br&gt;
Happy Holidays.&amp;nbsp; Merry Christmas!&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=b187e79b-18a4-4edc-a0e8-61932ac53ae3" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,b187e79b-18a4-4edc-a0e8-61932ac53ae3.aspx</comments>
      <category>.NET</category>
      <category>2.0</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=fd395a67-2ee8-4fe6-a0e6-08958e5ab80d</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,fd395a67-2ee8-4fe6-a0e6-08958e5ab80d.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,fd395a67-2ee8-4fe6-a0e6-08958e5ab80d.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=fd395a67-2ee8-4fe6-a0e6-08958e5ab80d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Spent Saturday getting my geek on at the
NOVA (Nothern Virigina to those of you outside of the greater Washington DC area) <a href="http://novacodecamp.org/">Code
Camp</a>.  The camp was pulled together by <a href="http://thequeue.net/blog/">Jeffrey
Schoolcraft</a> who marshalled a host of volunteers, speakers and contributors to
make it a great success.  If you didn't learn at least 10 things you probably
slept through all the sessions. Heck, I learned a bunch of things chatting between
sessions. Here's a smattering of what I learned.<br /><br /><ul><li>
It's time to start learning about <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx">WCF
(Windows Communication Foundation).</a>  This is going to be the way to build
distributed applications going forward, and it seems to get away from some of the
headaches of remoting and web services.  Definitely a great plumbing platform
that should make it easier to develop apps that span systems.<br /></li><li>
 <a href="http://msdn2.microsoft.com/en-us/library/ms754130.aspx">WPF (Windows
Presentation Foundation)</a> is going to be very interesting eventually and even has <a href="http://www.hanselman.com/blog/NYTimesReaderWPFsFirstKillerApp.aspx">some
cool implementations</a>, but the design tools aren't ahem, mature yet. But WPF will
further erode the line between desktop and web apps. Fortunately, <a href="http://www.xaml.net/">XAML</a> should
be very familiar to anyone who has been doing ASP.NET development.<br /></li><li>
I really need to get a copy of <a href="http://www.jetbrains.com/resharper/">Resharper</a> for
my daily refactoring.</li><li>
There's a <a href="http://www.searchdotnet.com/default.aspx">better way</a> to search
for useful .NET information without having to wade through unrelated results in Google
or other search engines.  
<br /></li><li>
I was introduced to <a href="http://www.raboof.com/projects/Elmah/">ELMAH, the library
I need</a> to use to replace the hand-rolled exception code I've been lugging around.</li><li>
When ordering pizza for an event the ratio of pepperoni pizzas to cheese pizzas should
be between 2:1 and 3:1. Not enough people actually like cheese pizza to make 1:1 a
viable ratio.<br /></li></ul>
Also got to meet a lot of people I had only known by name or online.  Not a bad
way to spend a Saturday.<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=fd395a67-2ee8-4fe6-a0e6-08958e5ab80d" /></body>
      <title>Things I Learned At Camp</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,fd395a67-2ee8-4fe6-a0e6-08958e5ab80d.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,fd395a67-2ee8-4fe6-a0e6-08958e5ab80d.aspx</link>
      <pubDate>Mon, 16 Apr 2007 14:32:13 GMT</pubDate>
      <description>Spent Saturday getting my geek on at the NOVA (Nothern Virigina to those of you outside of the greater Washington DC area) &lt;a href="http://novacodecamp.org/"&gt;Code
Camp&lt;/a&gt;.&amp;nbsp; The camp was pulled together by &lt;a href="http://thequeue.net/blog/"&gt;Jeffrey
Schoolcraft&lt;/a&gt; who marshalled a host of volunteers, speakers and contributors to
make it a great success.&amp;nbsp; If you didn't learn at least 10 things you probably
slept through all the sessions. Heck, I learned a bunch of things chatting between
sessions. Here's a smattering of what I learned.&lt;br&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
It's time to start learning about &lt;a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx"&gt;WCF
(Windows Communication Foundation).&lt;/a&gt;&amp;nbsp; This is going to be the way to build
distributed applications going forward, and it seems to get away from some of the
headaches of remoting and web services.&amp;nbsp; Definitely a great plumbing platform
that should make it easier to develop apps that span systems.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
&amp;nbsp;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms754130.aspx"&gt;WPF (Windows
Presentation Foundation)&lt;/a&gt; is going to be very interesting eventually and even has &lt;a href="http://www.hanselman.com/blog/NYTimesReaderWPFsFirstKillerApp.aspx"&gt;some
cool implementations&lt;/a&gt;, but the design tools aren't ahem, mature yet. But WPF will
further erode the line between desktop and web apps. Fortunately, &lt;a href="http://www.xaml.net/"&gt;XAML&lt;/a&gt; should
be very familiar to anyone who has been doing ASP.NET development.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
I really need to get a copy of &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper&lt;/a&gt; for
my daily refactoring.&lt;/li&gt;
&lt;li&gt;
There's a &lt;a href="http://www.searchdotnet.com/default.aspx"&gt;better way&lt;/a&gt; to search
for useful .NET information without having to wade through unrelated results in Google
or other search engines.&amp;nbsp; 
&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
I was introduced to &lt;a href="http://www.raboof.com/projects/Elmah/"&gt;ELMAH, the library
I need&lt;/a&gt; to use to replace the hand-rolled exception code I've been lugging around.&lt;/li&gt;
&lt;li&gt;
When ordering pizza for an event the ratio of pepperoni pizzas to cheese pizzas should
be between 2:1 and 3:1. Not enough people actually like cheese pizza to make 1:1 a
viable ratio.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
Also got to meet a lot of people I had only known by name or online.&amp;nbsp; Not a bad
way to spend a Saturday.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=fd395a67-2ee8-4fe6-a0e6-08958e5ab80d" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,fd395a67-2ee8-4fe6-a0e6-08958e5ab80d.aspx</comments>
      <category>.NET</category>
      <category>3.0</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=c163aa6c-bbc2-4175-a653-00e46e2de3a1</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,c163aa6c-bbc2-4175-a653-00e46e2de3a1.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,c163aa6c-bbc2-4175-a653-00e46e2de3a1.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=c163aa6c-bbc2-4175-a653-00e46e2de3a1</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There are four (development) life annoyances that I can do without:
</p>
        <ol>
          <li>
Recruiters who only use the state abbreviation to describe a job location. "Urgent
need for Senior .NET Developer, Location: CA"</li>
          <li>
Forum posters who demand code for entire applications. "Please send me chat server
code -- urgent."</li>
          <li>
Repeated requests for Interview Questions.  <a href="http://community.strongcoders.com/blogs/vpsw/archive/2006/10/23/the-only-interview-question-you-ll-ever-need-to-answer-click-here.aspx">I've
covered this elsewhere.</a><br /></li>
          <li>
Lazy gits who can't be bothered to learn how to read either C# or VB.NET. "Thanks
for the answer, but my project is in VB.NET, I don't understand C#."</li>
        </ol>
At least once a week, I'll answer a question on forum somewhere with a code example
and get a "Thank you, but" response.  Often accompanied by a request to rewrite
the code in their language of choice.  With perfectly named variables and smilies
in the comments.<br /><br />
This burns my toast.  It takes enormous willpower not to simply respond "find
another job you lazy git". 
<br /><br />
A) We're never talking more than 50 lines of code, usually it is around 20.  
<br />
B) 3/4 of the friggin' code is manipulating <b>.NET Framework objects</b> using <b>.NET
Framework methods</b> and <b>.NET Framework properties</b> -- which are -- wait for
it...<u><font color="#ff0000" size="4"><br /><br />
THE SAME FOR BOTH C# and VB.NET!</font></u><br /><br />
So this post is a (no longer) quick and dirty guide for figuring out how to translate
C# into VB.NET (and vice versa, but frankly 92.6% of the time its a VB coder who complains). 
It will become my standard response for all the future lazy gits.<br /><br />
Let's start at the top (of the class file that is)...<br /><br />
Need to reference a namespace...<br /><blockquote><font color="#0000ff">ala C#: using System.Data.SqlClient;</font><br /><font color="#008000">ala VB: Imports System.Data.SqlClient<br /></font><br /></blockquote>Note the ubiquitous semicolon (<b>;</b>).  C# statements can span
pages like a sentence in <a href="http://www.online-literature.com/james_joyce/ulysses/">Ulysses</a>. 
They don't end until the ; appears. VB statements get one line to do their business,
unless they are ended with the awkward _ line continuation (underscore) which allows
them to continue one more line unless they are ended with the awkward _, repeat.<br /><br />
A class...<br /><blockquote><font color="#0000ff">ala C#: public class TheClassINeverHad<br />
           {<br />
             //fields, methods and properties
-- oh my!<br />
            }<br /></font><font color="#008000">ala VB: Public Class TheClassINeverHad<br />
             'fields, methods and properties
-- oh my!<br />
          End Class<br /></font></blockquote> Ooooh no, C# does everything in lower case! (and its compiler
is very strict about keeping it that way)<br />
VB Capitalizes! (not that its compiler cares)<br /><br />
In C#, all code blocks are marked with with brackets{}. 
<br />
In VB, code blocks usually go until a line that starts with End followed by the type
of code block, which iin this case is Class.<br /><br />
Fancier class declarations...<br /><blockquote><font color="#0000ff">ala C#: public abstract class TheClassINeverHad</font><br /><font color="#008000">ala VB: Public MustInherit Class TheClassINeverHad</font><br /></blockquote><blockquote><font color="#0000ff">ala C#: public sealed class TheClassINeverHad</font><br /><font color="#008000">ala VB: Public NotInheritable Class TheClassINeverHad</font><br /></blockquote>Why VB.NET couldn't use the more common OOP vernacular is beyond me.<br /><br />
Interface declarations...<br /><blockquote><font color="#0000ff">ala C#: public interface IPractical</font><br /><font color="#008000">ala VB: Public Interface IPractical</font><br /></blockquote>Hooray, that should be clear even to the laziest git.<br /><br />
Extending a class...<br /><blockquote><font color="#0000ff">ala C#: public class TheClassINeverHad: APracticalClass</font><br /><font color="#008000">ala VB: Public Class TheClassINeverHad<br />
             Inherits APracticalClass<br /></font></blockquote>The humble colon does a lot here in C#.  The VB syntax leaves
nothing to doubt.<br /><br />
Implementing an interface...<br /><blockquote><font color="#0000ff">ala C#: public class TheClassINeverHad: IPractical</font><br /><font color="#008000">ala VB: Public Class TheClassINeverHad<br />
             Implements IPractical<br /></font></blockquote>or interfaces...<br /><blockquote><font color="#0000ff">ala C#: public class TheClassINeverHad: IPractical,
IRidiculous</font><br /><font color="#008000">ala VB: Public Class TheClassINeverHad<br />
             Implements IPractical<br />
             Implements IRidiculous<br /></font></blockquote>The colon does everything!  
<br /><br />
Extending and implementing...<br /><blockquote><font color="#0000ff">ala C#: public class TheClassINeverHad: APracticalClass,
IPractical, IRidiculous</font><br /><font color="#008000">ala VB: Public Class TheClassINeverHad<br />
             Inherits APracticalClass<br /></font><font color="#008000">             
Implements IPractical</font><br /><font color="#008000">              Implements
IRidiculous</font><br /></blockquote> A comment...<br /><blockquote><font color="#0000ff">ala C#: //This is a 1 line comment<br />
          /* This starts a multiline comment<br />
          This ends a multiline comment */<br /></font><font color="#008000">ala VB: 'This is a one line comment<br /></font></blockquote>There is no such thing as a multline comment in VB, but who comments
code anyway?<br /><br />
You really should though.<br /><br />
a field...<br /><blockquote><font color="#0000ff">ala C#: private int SomeNumberIWillUse;</font><br /><font color="#008000">ala VB: Private SomeNumberIWillUse as Integer</font><br /></blockquote> VB.NET surrounds the name of the variable with its access modifier and
type.  C# gets all that out of the way then tells you the name.<br /><br />
a constant...<br /><blockquote><font color="#0000ff">ala C#: private const string LAZY_GIT = "Lazy Git";</font><br /><font color="#008000">ala VB: Private Const LAZY_GIT as String = "Lazy Git"</font><br /></blockquote>a constructor...<br /><blockquote><font color="#0000ff">ala C#: public TheClassINeverHad()<br />
            {<br />
                //Do Something
Useful<br />
             }<br /></font><font color="#008000">ala VB: public Sub New()<br />
             'Do Something Useful<br />
          End Sub<br /></font></blockquote><font color="#008000"><br /></font>C# uses the name of the class to indicate the constructor. The Sub New in VB
is a little clearer at first blush.<br /><br />
A structure can be a handy little doo-dad when a class is overkill...<br /><blockquote><font color="#0000ff">ala C#: public struct Soda<br />
           {<br />
                 public
string Name;<br />
                 public int
Calories;<br />
            }<br /></font><font color="#008000">ala VB: Public Structure Soda<br />
             Public Name as String<br />
             Public Calories as Integer<br />
          End Structure<br /></font></blockquote> More brackets in C#, another End statement in VB. C# shows it
inclination for abbreviation. Patterns develop.<br /><br />
Let's not forget enumerations...<br /><blockquote><font color="#0000ff">ala C#: public enum PlanetValues<br />
           {<br />
                   
Mercury = 0,<br />
                   
Venus = 1,<br />
                   
Earth = 2,<br />
                   
Mars = 3,<br />
                   
Jupiter = 4,<br />
                   
Saturn = 5,<br />
                   
Uranus = 6,<br />
                   
Neptune = 7,<br />
                   
Pluto = 8<br />
            }<br /></font><font color="#0000ff">           
public enum PlanetValues<br />
           {<br />
                   
Mercury,<br />
                   
Venus,<br />
                   
Earth,<br />
                   
Mars,<br />
                   
Jupiter,<br />
                   
Saturn,<br />
                   
Uranus,<br />
                   
Neptune,<br />
                   
Pluto<br />
            }</font><br /><font color="#008000">ala VB: Public Enum PlanetValues<br />
             Mercury = 0<br />
             Venus = 1<br />
             Earth = 2<br />
             Mars = 3<br />
             Jupiter = 4<br />
             Saturn = 5<br />
             Uranus = 6<br />
             Neptune = 7<br />
             Pluto = 8<br />
          End Enum<br /><br /></font><font color="#008000">        Public Enum PlanetValues<br />
             Mercury 
<br />
             Venus 
<br />
             Earth 
<br />
             Mars 
<br />
             Jupiter 
<br />
             Saturn 
<br />
             Uranus 
<br />
             Neptune 
<br />
             Pluto 
<br />
          End Enum</font><br /></blockquote>All these enumerations are identical.  If no value for the first
element is specified it is set = 0, every other unspecified element is incremented
one from the previous element. Curiously the C# syntax uses commas and not semi-colons.<br /><br />
a local variable...<br /><blockquote><font color="#0000ff">ala C#: string DeveloperPersona;</font><br /><font color="#008000">ala VB: Dim DeveloperPersona as String</font><font color="#008000"><br /></font></blockquote>arrays...<br /><blockquote><font color="#0000ff">ala C#: string[] CoolDevTools;<br />
           string[] CoolDevTools = new string[5];<br />
           //assignment<br />
          CoolDevTools[0] = SomeString;<br /></font><font color="#008000">ala VB: Dim CoolDevTools as String()<br />
          Dim CoolDevTools(5) as String<br />
          'assignment<br />
          CoolDevTools(0) = SomeString<br />
              </font><br /></blockquote>C# uses square brackets [] for the elements.<br />
VB uses parentheses ().<br /><br />
Ditto for collection elements...<br /><blockquote><font color="#0000ff">ala C#: AnObjectType SomeObject = (</font><font color="#0000ff">AnObjectType)</font><font color="#0000ff">SomeHashtable[SomeKey];<br />
           A</font><font color="#0000ff">nObjectType
SomeObject = (</font><font color="#0000ff">AnObjectType)</font><font color="#0000ff">SomeArrayList[SomeIndex];</font><font color="#0000ff"><br /></font><font color="#008000">ala VB:  Dim SomeObject as AnObjectType = SomeHashtable(SomeKey)<br />
           </font><font color="#008000">Dim
SomeObject as AnObjectType = SomeArrayList(SomeIndex)</font><br /><font color="#008000">           'or if Option
Strict is on<br />
          D</font><font color="#008000">im SomeObject
as AnObjectType = CType(SomeHashtable(SomeKey), AnObjectType)<br />
          </font><font color="#008000">Dim SomeObject
as AnObjectType = </font><font color="#008000">CType(</font><font color="#008000">SomeArrayList(SomeIndex)</font><font color="#008000">,
AnObjectType)</font><br /><font color="#008000">               </font></blockquote>C#
doesn't do narrowing implicit type casts,  so an element retrieved from an untyped
collection must be explicitly cast.  This is done by wrapping the object type
in parentheses and smooshing it against the collection name.<br />
VB will implicitly cast unless <a href="http://msdn2.microsoft.com/en-us/library/zcd4xwzs%28vs.71%29.aspx">Option
Strict </a>is On, in which case the CType method must be used to cast the element
returned to the proper type.<br /><br />
a method that does NOT return a value...<br /><blockquote><font color="#0000ff">ala C#: public void ThePerfectMethod(string DeveloperName)<br />
             {<br />
                // coding goodness<br />
             }<br /></font><font color="#008000">ala VB: Public Sub ThePerfectMethod(DeveloperName as
String)<br />
                'Coding Goodness<br />
          End Sub<br /></font></blockquote>a method that does return a value...<br /><blockquote><font color="#0000ff">ala C#: public int ThePerfectMethod(string DeveloperName)<br />
             {<br />
                // coding goodness<br />
               
return 42;<br />
             }<br /></font><font color="#008000">ala VB: Public Function ThePerfectMethod(DeveloperName
as String) as Integer<br />
                'Coding Goodness<br />
                Return 42<br />
          End Function<br /></font></blockquote> As with fields and constants, C# states the access modifier and
the type being returned by the method before getting to the name.  When nothing
is returned the type is <b>void</b>.<br />
VB has separate keywords to differentiate between methods that return nada (Sub) and
those that return something (Function).<br />
Parameters are types just like variables are in each language:  type Name in
C#, Name as Type in VB.<br /><br />
a read/write property...<br /><blockquote><font color="#0000ff">ala C#: public int TheAnswer<br />
             {<br />
               get{  
return mTheAnswer;}<br />
               set{  mTheAnswer
= value;}<br />
             }<br /></font><font color="#008000">ala VB: Public Property TheAnswer() as Integer<br />
                Get<br />
                   
Return mTheAnswer<br />
                End Get<br />
                Set (Value
as Integer)<br />
                  
mTheAnswer = Value<br />
                End Set<br />
                  
   
<br />
          End Property</font><br /></blockquote>a read-only property...<br /><blockquote><blockquote><font color="#0000ff">ala C#: public int TheAnswer<br />
             {<br />
               get{  
return mTheAnswer;}<br />
             }<br /></font><font color="#008000">ala VB: Public ReadOnly Property TheAnswer() as Integer<br />
                Get<br />
                   
Return mTheAnswer<br />
                End Get<br />
          End Property<br /></font></blockquote></blockquote>a write-only property...<br /><blockquote><font color="#0000ff">ala C#: public int TheAnswer<br />
             {<br />
               set{  mTheAnswer
= value;}<br />
             }<br /></font><font color="#008000">ala VB: Public WriteOnly Property TheAnswer() as Integer<br />
                Set (Value
as Integer)<br />
                  
mTheAnswer = Value<br />
                End Set<br />
                  
   
<br />
          End Property</font></blockquote>VB.NET
needs to be explicity told a property is read- or write-only, C# is happy as long
as there is a get or set -- it figures it out.<br /><br />
static(Shared) members...<br /><blockquote><font color="#0000ff">ala C#: private static int mANumberEveryoneNeeds;<br />
           public static ANumberEveryoneNeeds<br />
           {<br />
                get{return </font><font color="#0000ff">mANumberEveryoneNeeds;}</font><br /><font color="#0000ff">           }<br />
           public static void ResetTheNumber()<br />
           {<br />
                </font><font color="#0000ff">mANumberEveryoneNeeds
= 0;</font><br /><font color="#0000ff">           }<br /></font><font color="#008000">ala VB: Private Shared mANumberEveryonNeeds as Integer<br />
           Public Readonly Shared Property
ANumberEveryoneNeeds() as Integer<br />
                Get<br />
                  
Return mANumberEveryoneNeeds<br />
                End Get<br />
           End Property<br />
           Public Shared Sub ResetTheNumber
()<br />
                
mANumberEveryoneNeeds = 0<br />
           End Sub<br /></font></blockquote><br />
Shared = static.  static = Shared. Static members are shared by ALL instances
of a class.  The meaning of static is not as immediately a clear as Shared. But
it's not that hard to remember.<br /><br />
Branching...<br /><blockquote><font color="#0000ff">ala C#: if(SomeVariable == 42)<br />
             {<br />
                Answer = "That's
it!";<br />
                HasWisdom = true;<br />
             }<br />
           else<br />
             {<br />
                Answer = "That's
not it.";<br />
               
HasWisdon = false;<br />
             }<br /><br />
          //one line syntax<br /></font><font color="#0000ff">           if(SomeVariable
== 42)<br />
                Answer = "That's
it!";<br />
           else<br />
                Answer = "That's
not it.";<br />
                </font><br /><font color="#0000ff"></font><font color="#0000ff"><br /></font><font color="#008000">ala VB: If SomeVariable = 42 Then<br />
             Answer = "That's it!"<br />
             HasWisdom
= True<br />
          Else<br />
             Answer = "That's not it."<br />
             HasWisdom
= False<br />
          End if<br /></font></blockquote>There's no Then in C#, the boolean expression is wrapped in parentheses
and the code to execute is within {}. The brackets are not required if the condition
only executes one line.  Like most other constructs in VB, the code block ends
with a uniquely named End statement: End If. 
<br /><br />
Note in C# the == is an evaluation operator, as opposed to the assignment operator
=.  In VB = performs both tasks. 
<br /><br />
What fun is an If statement without boolean logic...<br /><blockquote><font color="#0000ff">ala C#: if(!Page.IsPostBack) //Not operator<br />
           </font><font color="#0000ff">if(Night
!= Day) //Inequality<br />
           </font><font color="#0000ff">if(Night
== Day &amp; Pigs.CurrentState == PigState.Flying) // And</font><br /><font color="#0000ff">           if(</font><font color="#0000ff">Night
== Day &amp;&amp; Pigs.CurrentState == PigState.Flying</font><font color="#0000ff">)
//Conditional And<br />
           </font><font color="#0000ff">if(Night
== Day | Pigs.CurrentState == PigState.Flying) // Or<br />
           </font><font color="#0000ff">if(Night
== Day || Pigs.CurrentState == PigState.Flying) // Conditional Or<br />
           </font><font color="#0000ff">if(Night
== Day ^ Pigs.CurrentState == PigState.Flying) // Xor</font><br /><br /><font color="#0000ff"><br /></font><font color="#008000">ala VB: If Not Page.IsPostBack Then<br />
           If Night &lt;&gt; Day Then 'Inequality<br />
           If Night = Day And Pigs.CurrentState
= PigState.Flying Then 
<br />
           </font><font color="#008000">If
Night = Day AndAlso Pigs.CurrentState = PigState.Flying Then 'Conditional And</font><br /><font color="#008000">           If Night
= Day Or Pigs.CurrentState = PigState.Flying Then 
<br />
           </font><font color="#008000">If
Night = Day OrElse Pigs.CurrentState = PigState.Flying Then 'Conditional Or<br />
           </font><font color="#008000">If
Night = Day Xor Pigs.CurrentState = PigState.Flying Then</font><br /><font color="#008000">            
<br /></font></blockquote>VB spells everything out, though &lt;&gt; is a unique feature
of the language.  The conditional operators AndAlso (&amp;&amp;) and OrElse(||)
are tres useful, they short circuit the code and stop evaluting as soon as the appropriate
condition is met. 
<br /><br />
And when If Then is isn't enough...<br /><blockquote><font color="#0000ff">ala C#: </font><font color="#0000ff">switch(SelectedPlanet)</font><br /><font color="#0000ff">            {<br />
                 case
PlanetValues.Earth:<br />
                     
message = "Live there";<br />
                     
break;<br />
                 case
PlanetValues.Venus:<br />
                 case
PlanetValues.Mars:<br />
                  
   message = "Landed there";<br />
                  
   break;<br />
                 </font><font color="#0000ff">case
PlanetValues.Mercury:<br />
                 case
PlanetValues.Jupiter:<br />
                 case
PlanetValues.Saturn:<br />
                 case
PlanetValues.Uranus:<br />
                 case
PlanetValues.Neptune:<br />
                  
   message = "Flew by";<br />
                  
   break;<br />
                  case
PlanetValues.Pluto:<br />
                  
   message = "Is it a planet?"<br />
                  
   break;<br />
                  
default:<br />
                  
   message = "Never heard of it";<br />
                  
   break;<br />
           }</font><font color="#0000ff"><br />
            </font><font color="#0000ff"><br /></font><font color="#008000">ala VB: Select Case SelectedPlanet<br />
                Case PlanetValues.Earth<br />
                  
message = "Live there"<br />
                Case PlanetValues.Venus,
PlanetValues.Mars<br />
                  
message = "Landed there"<br />
                Case PlanetValues.Mercury,
PlanetValues.Jupiter, PlanetValues.Saturn, PlanetValues.Uranus, PlanetValues.Neptune<br />
                  
message = "Flew by"<br />
                Case PlanetValues.Pluto<br />
                  
message = "Is it a planet?"<br />
                Case Else<br />
                  
message = "Never heard of it"<br />
          End Select</font><font color="#008000"></font><br /></blockquote>In C#, there's only one value per case, but once a supplied value matches
a case, the code will "fall through" until it finds a case that executes code. 
All cases that have code must end with a break;. 
<br />
In VB, multiple values can be present on a line, it's also possible to do <a href="http://msdn2.microsoft.com/en-us/library/cy37t14y%28VS.71%29.aspx">ranges.</a> The
code cannot fall through in VB, but the extra flexibility for defining case values
makes it unecessary. 
<br /><br />
For Loops...<br /><blockquote><font color="#0000ff">ala C#: for(int Index = 0; Index &lt; SomeIntegerArray.Length;
Index ++)<br />
             {<br />
                 Total
+= SomeIntegerArray[Index];<br />
                 CallSomeOtherFunction(SomeIntegerArray[Index]);<br />
             }<br />
             //A single line For Loop
can be done without the brackets<br />
            </font><font color="#0000ff">for(int
Index = 0; Index &lt; SomeIntegerArray.Length; Index ++)<br />
                </font><font color="#0000ff">Total
+= SomeIntegerArray[Index];<br /></font><font color="#0000ff"><br /></font><font color="#008000">ala VB: For Index as Integer = 0 to SomeIntegerArray.Length
-1<br />
                Total += SomeIntegerArray(Index)<br />
                CallSomeOtherFunction(SomeIntegerArray(Index))<br />
          Next</font></blockquote><br />
In C#, {} brackets define what code gets looped, but a single line statement does
not require brackets. Iteration step size is always specified<br />
VB always requires the Next statement.  The iteration step size defaults to 1
for VB, to change the iteration step size...<br /><br /><blockquote><font color="#0000ff">ala C#: for(int Index = 0; Index &lt; SomeIntegerArray.Length;
Index += 2)<br />
             {<br />
                 Total
+= SomeIntegerArray[Index];<br />
                 CallSomeOtherFunction(SomeIntegerArray[Index]);<br />
             }<br />
            </font><font color="#0000ff"><br /></font><font color="#0000ff"><br /></font><font color="#008000">ala VB: For Index as Integer = 0 to SomeIntegerArray.Length
-1 Step 2<br />
                Total += SomeIntegerArray(Index)<br />
                </font><font color="#008000">CallSomeOtherFunction(SomeIntegerArray(Index))</font><br /><font color="#008000">           Next</font></blockquote>To
break out of the loop before it completes...<br /><blockquote><font color="#0000ff">ala C#: for(int Index = 0; Index &lt; SomeIntegerArray.Length;
Index += 2)<br />
             {<br />
                 Total
+= SomeIntegerArray[Index];<br />
                 if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)<br />
                  
break;<br />
             }</font><font color="#0000ff"><br /></font><font color="#0000ff"><br /></font><font color="#008000">ala VB: For Index as Integer = 0 to SomeIntegerArray.Length
-1 Step 2<br />
                Total += SomeIntegerArray(Index)<br />
                If </font><font color="#008000">CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then<br />
                  
Exit For<br />
                End if<br /></font><font color="#008000">           Next</font></blockquote>break
is used to get out of every kind of loop in C#.  The command for exiting a loop
in VB.NET depends on the type of the loop. This can come in handy for nested loops
of different types.<br /><br />
For each loops...<br /><br /><blockquote><font color="#0000ff">ala C#: foreach(Universe PossibleUniverse in PossibleUniverses)<br />
             {<br />
                 if(PossibleUniverse.HasStrongForce)<br />
                 {<br />
                  
   
<br />
                  
   AddToViableCandidates(PossibleUniverse);<br />
                 }<br />
             }<br />
            </font><font color="#0000ff"><br /></font><font color="#0000ff"><br /></font><font color="#008000">ala VB: For Each PossibleUniverse as Universe in PossibleUniverses 
<br />
                If PossibleUniverse.HasStrongForce
Then<br />
                  
AddToViableCandidates(PossibleUniverse)<br />
                End if<br />
          Next<br /><br /></font></blockquote>Ignore the brackets and the for each loops look a lot alike.<br /><br /><br />
Do While Loops...<br /><blockquote><font color="#0000ff">ala C#: do<br />
             {<br />
                 Total
+= SomeIntegerArray[Index];<br />
                 if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)<br />
                  
break;<br />
                 Index++;<br />
             }<br />
             while(Index &lt; SomeIntegerArray.Length);<br /></font><font color="#0000ff"><br /></font><font color="#008000">ala VB: Do<br />
                Total += SomeIntegerArray(Index)<br />
                If </font><font color="#008000">CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then<br />
                  
Exit Do<br />
                End if<br />
               
Index += 1<br /></font><font color="#008000">           Loop While
Index &lt; SomeIntegerArray.Length<br /><br /></font><font color="#008000">          Do </font><font color="#008000">While
Index &lt; SomeIntegerArray.Length</font><br /><font color="#008000">                
Total += SomeIntegerArray(Index)<br />
                If </font><font color="#008000">CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then<br />
                  
Exit Do<br />
                End if<br />
                Index += 1<br /></font><font color="#008000">           Loop </font><br /></blockquote><br />
The do loop in C# always executes at least once.  The top version of the VB loop
does as well.  While the second version evaluates the condition before executing.
This is the one of the few code structures in VB that doesn't denote it's end using
an End statement (the others being the for and for each loops). If it did it would
look something like this...<br /><font color="#ff1493"><br />
          'This is not legal syntax -- just what
a Do loop would look like if VB were maddeningly consistent<br />
          Do<br />
                Total +=SomeIntegerArray(Index)<br />
          End Do While Index &lt; SomeIntegerArray.Length<br /></font><br />
Which is just goofy.<br /><br />
Do Until Loops...<br /><blockquote><font color="#0000ff">ala C#: do<br />
             {<br />
                 Total
+= SomeIntegerArray[Index];<br />
                 if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)<br />
                  
break;<br />
                 Index++;<br />
             }<br />
             while(Index &lt; SomeIntegerArray.Length);<br /></font><font color="#0000ff"><br /></font><font color="#008000">ala VB: Do<br />
                Total += SomeIntegerArray(Index)<br />
                If </font><font color="#008000">CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then<br />
                  
Exit Do<br />
                End if<br />
                Index += 1<br /></font><font color="#008000">           Loop Until
Index = SomeIntegerArray.Length<br /><br /></font><font color="#008000">          Do </font><font color="#008000">Until
Index = SomeIntegerArray.Length</font><br /><font color="#008000">                
Total += SomeIntegerArray(Index)<br />
                If </font><font color="#008000">CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then<br />
                  
Exit Do<br />
                End if<br />
                Index += 1<br /></font><font color="#008000">           Loop </font><br /></blockquote><br />
Wait a second -- there's no <b>do until</b> in C#. <b>Until</b> is just the other
side of <b>while</b>.  Instead of executing <b>while</b> a condition is true,
it executes <b>until</b> it is true. When moving from VB.NET to C# just use the while
and flip the condition to its opposite. Again the C# loop and the first VB loop execute
at least once.  
<br /><br />
And the last loop is the plain old while loop...<br /><blockquote><font color="#0000ff">ala C#: </font><font color="#0000ff">while(Index
&lt; SomeIntegerArray.Length)</font><br /><font color="#0000ff">              {<br />
                 Total
+= SomeIntegerArray[Index];<br />
                 if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)<br />
                  
break;<br />
                 Index++;<br />
             }<br />
            </font><font color="#0000ff"><br /></font><font color="#008000">ala VB: While </font><font color="#008000">Index &lt;
SomeIntegerArray.Length<br /></font><br /><font color="#008000">                
Total += SomeIntegerArray(Index)<br />
                If </font><font color="#008000">CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then<br />
                  
Exit While<br />
                End if<br />
                Index += 1<br /></font><font color="#008000">           End 
While 
<br /></font><font color="#008000">         </font><font color="#008000"></font><br /></blockquote> While loops in both languages evaluate the condition before executing. 
Note the while uses the familiar Exit While to break and the End While to terminate
the loop.<br /><br />
Finally, a tricky difference -- hooking up event handlers...<br /><blockquote><font color="#0000ff">ala C#: </font><font color="#0000ff">SomeButton.Click
+= new ButtonEventHandler(SomeButton_Click);</font><font color="#0000ff"></font><br /><font color="#0000ff">             </font><br /><font color="#008000">ala VB: AddHandler SomeButton.Click, AddressOf SomeButton_Click</font><br /><br /><font color="#008000">          'or directly declare
it</font><br /><font color="#008000">           Sub SomeButton_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles SomeButton.Click</font><br /></blockquote>VB lets you hook up the Handler on the event declaration or add the handler
dynamically.  C# only allows the dynamic hook.  
<br /><br />
I think this post has sufficiently covered 93.7% of commonly encountered code. 
I'd cover <a href="http://msdn2.microsoft.com/en-us/library/512aeb7t.aspx">Generics</a> (<a href="http://msdn2.microsoft.com/en-us/library/ms379608%28vs.80%29.aspx">VB
usage)</a>  but I think anyone working with Generics probably doesn't have any
problems reading either language.<br /><br />
Here are some reference links...<br /><ul><li><a href="http://msdn2.microsoft.com/en-us/library/6a71f45d.aspx">C# Operators</a></li><li><a href="http://msdn2.microsoft.com/en-us/library/x53a06bb.aspx">C# Keywords</a></li><li><a href="http://msdn2.microsoft.com/en-us/library/ksh7h19t%28VS.71%29.aspx">VB.NET
Keywords</a></li><li><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxgrfLanguageEquivalents.asp">Language
Equivalents</a></li></ul>
And for the truly lazy or people who have to translate more than 20 lines of code,
there are converters (though you might get some <a href="http://www.vpsw.com/blogbaby/PermaLink,guid,bb634e82-a78f-4fca-9d5d-a63616d70f99.aspx">interesting
results</a>) ...<br /><ul><li><a href="http://www.tangiblesoftwaresolutions.com/">Tanglible Software</a></li><li><a href="http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx">Developer
Fusion</a></li><li><a href="http://www.google.com/search?q=c%23+vb+converter&amp;sourceid=navclient-ff&amp;ie=UTF-8&amp;rlz=1B3GGGL_enUS176US213&amp;aq=t">Or
Google For More</a></li></ul>
So learn 'em both -- double your code examples, double your employment opportunities
-- double your fun.<br /><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=c163aa6c-bbc2-4175-a653-00e46e2de3a1" /></body>
      <title>Airing of Grievances</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,c163aa6c-bbc2-4175-a653-00e46e2de3a1.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,c163aa6c-bbc2-4175-a653-00e46e2de3a1.aspx</link>
      <pubDate>Fri, 30 Mar 2007 22:12:15 GMT</pubDate>
      <description>&lt;p&gt;
There are four (development) life annoyances that I can do without:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Recruiters who only use the state abbreviation to describe a job location. "Urgent
need for Senior .NET Developer, Location: CA"&lt;/li&gt;
&lt;li&gt;
Forum posters who demand code for entire applications. "Please send me chat server
code -- urgent."&lt;/li&gt;
&lt;li&gt;
Repeated requests for Interview Questions.&amp;nbsp; &lt;a href="http://community.strongcoders.com/blogs/vpsw/archive/2006/10/23/the-only-interview-question-you-ll-ever-need-to-answer-click-here.aspx"&gt;I've
covered this elsewhere.&lt;/a&gt;
&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
Lazy gits who can't be bothered to learn how to read either C# or VB.NET. "Thanks
for the answer, but my project is in VB.NET, I don't understand C#."&lt;/li&gt;
&lt;/ol&gt;
At least once a week, I'll answer a question on forum somewhere with a code example
and get a "Thank you, but" response.&amp;nbsp; Often accompanied by a request to rewrite
the code in their language of choice.&amp;nbsp; With perfectly named variables and smilies
in the comments.&lt;br&gt;
&lt;br&gt;
This burns my toast.&amp;nbsp; It takes enormous willpower not to simply respond "find
another job you lazy git". 
&lt;br&gt;
&lt;br&gt;
A) We're never talking more than 50 lines of code, usually it is around 20.&amp;nbsp; 
&lt;br&gt;
B) 3/4 of the friggin' code is manipulating &lt;b&gt;.NET Framework objects&lt;/b&gt; using &lt;b&gt;.NET
Framework methods&lt;/b&gt; and &lt;b&gt;.NET Framework properties&lt;/b&gt; -- which are -- wait for
it...&lt;u&gt;&lt;font color="#ff0000" size="4"&gt;
&lt;br&gt;
&lt;br&gt;
THE SAME FOR BOTH C# and VB.NET!&lt;/font&gt;&lt;/u&gt;
&lt;br&gt;
&lt;br&gt;
So this post is a (no longer) quick and dirty guide for figuring out how to translate
C# into VB.NET (and vice versa, but frankly 92.6% of the time its a VB coder who complains).&amp;nbsp;
It will become my standard response for all the future lazy gits.&lt;br&gt;
&lt;br&gt;
Let's start at the top (of the class file that is)...&lt;br&gt;
&lt;br&gt;
Need to reference a namespace...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: using System.Data.SqlClient;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Imports System.Data.SqlClient&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;Note the ubiquitous semicolon (&lt;b&gt;;&lt;/b&gt;).&amp;nbsp; C# statements can span
pages like a sentence in &lt;a href="http://www.online-literature.com/james_joyce/ulysses/"&gt;Ulysses&lt;/a&gt;.&amp;nbsp;
They don't end until the ; appears. VB statements get one line to do their business,
unless they are ended with the awkward _ line continuation (underscore) which allows
them to continue one more line unless they are ended with the awkward _, repeat.&lt;br&gt;
&lt;br&gt;
A class...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public class TheClassINeverHad&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //fields, methods and properties
-- oh my!&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Public Class TheClassINeverHad&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'fields, methods and properties
-- oh my!&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Class&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt; Ooooh no, C# does everything in lower case! (and its compiler
is very strict about keeping it that way)&lt;br&gt;
VB Capitalizes! (not that its compiler cares)&lt;br&gt;
&lt;br&gt;
In C#, all code blocks are marked with with brackets{}. 
&lt;br&gt;
In VB, code blocks usually go until a line that starts with End followed by the type
of code block, which iin this case is Class.&lt;br&gt;
&lt;br&gt;
Fancier class declarations...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public abstract class TheClassINeverHad&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public MustInherit Class TheClassINeverHad&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt; &lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public sealed class TheClassINeverHad&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public NotInheritable Class TheClassINeverHad&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;Why VB.NET couldn't use the more common OOP vernacular is beyond me.&lt;br&gt;
&lt;br&gt;
Interface declarations...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public interface IPractical&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public Interface IPractical&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;Hooray, that should be clear even to the laziest git.&lt;br&gt;
&lt;br&gt;
Extending a class...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public class TheClassINeverHad: APracticalClass&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public Class TheClassINeverHad&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Inherits APracticalClass&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;The humble colon does a lot here in C#.&amp;nbsp; The VB syntax leaves
nothing to doubt.&lt;br&gt;
&lt;br&gt;
Implementing an interface...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public class TheClassINeverHad: IPractical&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public Class TheClassINeverHad&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Implements IPractical&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;or interfaces...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public class TheClassINeverHad: IPractical,
IRidiculous&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public Class TheClassINeverHad&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Implements IPractical&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Implements IRidiculous&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;The colon does everything!&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
Extending and implementing...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public class TheClassINeverHad: APracticalClass,
IPractical, IRidiculous&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public Class TheClassINeverHad&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Inherits APracticalClass&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
Implements IPractical&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Implements
IRidiculous&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt; A comment...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: //This is a 1 line comment&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* This starts a multiline comment&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; This ends a multiline comment */&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: 'This is a one line comment&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;There is no such thing as a multline comment in VB, but who comments
code anyway?&lt;br&gt;
&lt;br&gt;
You really should though.&lt;br&gt;
&lt;br&gt;
a field...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: private int SomeNumberIWillUse;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Private SomeNumberIWillUse as Integer&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt; VB.NET surrounds the name of the variable with its access modifier and
type.&amp;nbsp; C# gets all that out of the way then tells you the name.&lt;br&gt;
&lt;br&gt;
a constant...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: private const string LAZY_GIT = "Lazy Git";&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Private Const LAZY_GIT as String = "Lazy Git"&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;a constructor...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public TheClassINeverHad()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //Do Something
Useful&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: public Sub New()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'Do Something Useful&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Sub&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt; &lt;font color="#008000"&gt;
&lt;br&gt;
&lt;/font&gt;C# uses the name of the class to indicate the constructor. The Sub New in VB
is a little clearer at first blush.&lt;br&gt;
&lt;br&gt;
A structure can be a handy little doo-dad when a class is overkill...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public struct Soda&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&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; public
string Name;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; public int
Calories;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Public Structure Soda&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Public Name as String&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Public Calories as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Structure&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt; More brackets in C#, another End statement in VB. C# shows it
inclination for abbreviation. Patterns develop.&lt;br&gt;
&lt;br&gt;
Let's not forget enumerations...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public enum PlanetValues&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&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;
Mercury = 0,&lt;br&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;
Venus = 1,&lt;br&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;
Earth = 2,&lt;br&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;
Mars = 3,&lt;br&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;
Jupiter = 4,&lt;br&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;
Saturn = 5,&lt;br&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;
Uranus = 6,&lt;br&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;
Neptune = 7,&lt;br&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;
Pluto = 8&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
public enum PlanetValues&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&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;
Mercury,&lt;br&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;
Venus,&lt;br&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;
Earth,&lt;br&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;
Mars,&lt;br&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;
Jupiter,&lt;br&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;
Saturn,&lt;br&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;
Uranus,&lt;br&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;
Neptune,&lt;br&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;
Pluto&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Public Enum PlanetValues&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Mercury = 0&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Venus = 1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Earth = 2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Mars = 3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Jupiter = 4&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Saturn = 5&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Uranus = 6&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Neptune = 7&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Pluto = 8&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Enum&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Enum PlanetValues&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Mercury 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Venus 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Earth 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Mars 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Jupiter 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Saturn 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Uranus 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Neptune 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Pluto 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Enum&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;All these enumerations are identical.&amp;nbsp; If no value for the first
element is specified it is set = 0, every other unspecified element is incremented
one from the previous element. Curiously the C# syntax uses commas and not semi-colons.&lt;br&gt;
&lt;br&gt;
a local variable...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: string DeveloperPersona;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: Dim DeveloperPersona as String&lt;/font&gt;&lt;font color="#008000"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;arrays...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: string[] CoolDevTools;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; string[] CoolDevTools = new string[5];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //assignment&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; CoolDevTools[0] = SomeString;&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Dim CoolDevTools as String()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Dim CoolDevTools(5) as String&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'assignment&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; CoolDevTools(0) = SomeString&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;C# uses square brackets [] for the elements.&lt;br&gt;
VB uses parentheses ().&lt;br&gt;
&lt;br&gt;
Ditto for collection elements...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: AnObjectType SomeObject = (&lt;/font&gt;&lt;font color="#0000ff"&gt;AnObjectType)&lt;/font&gt;&lt;font color="#0000ff"&gt;SomeHashtable[SomeKey];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/font&gt;&lt;font color="#0000ff"&gt;nObjectType
SomeObject = (&lt;/font&gt;&lt;font color="#0000ff"&gt;AnObjectType)&lt;/font&gt;&lt;font color="#0000ff"&gt;SomeArrayList[SomeIndex];&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB:&amp;nbsp; Dim SomeObject as AnObjectType = SomeHashtable(SomeKey)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000"&gt;Dim
SomeObject as AnObjectType = SomeArrayList(SomeIndex)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'or if Option
Strict is on&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; D&lt;/font&gt;&lt;font color="#008000"&gt;im SomeObject
as AnObjectType = CType(SomeHashtable(SomeKey), AnObjectType)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000"&gt;Dim SomeObject
as AnObjectType = &lt;/font&gt;&lt;font color="#008000"&gt;CType(&lt;/font&gt;&lt;font color="#008000"&gt;SomeArrayList(SomeIndex)&lt;/font&gt;&lt;font color="#008000"&gt;,
AnObjectType)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/blockquote&gt;C#
doesn't do narrowing implicit type casts,&amp;nbsp; so an element retrieved from an untyped
collection must be explicitly cast.&amp;nbsp; This is done by wrapping the object type
in parentheses and smooshing it against the collection name.&lt;br&gt;
VB will implicitly cast unless &lt;a href="http://msdn2.microsoft.com/en-us/library/zcd4xwzs%28vs.71%29.aspx"&gt;Option
Strict &lt;/a&gt;is On, in which case the CType method must be used to cast the element
returned to the proper type.&lt;br&gt;
&lt;br&gt;
a method that does NOT return a value...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public void ThePerfectMethod(string DeveloperName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // coding goodness&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Public Sub ThePerfectMethod(DeveloperName as
String)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'Coding Goodness&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Sub&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;a method that does return a value...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public int ThePerfectMethod(string DeveloperName)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // coding goodness&lt;br&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;
return 42;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Public Function ThePerfectMethod(DeveloperName
as String) as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'Coding Goodness&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Return 42&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Function&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt; As with fields and constants, C# states the access modifier and
the type being returned by the method before getting to the name.&amp;nbsp; When nothing
is returned the type is &lt;b&gt;void&lt;/b&gt;.&lt;br&gt;
VB has separate keywords to differentiate between methods that return nada (Sub) and
those that return something (Function).&lt;br&gt;
Parameters are types just like variables are in each language:&amp;nbsp; type Name in
C#, Name as Type in VB.&lt;br&gt;
&lt;br&gt;
a read/write property...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public int TheAnswer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; get{&amp;nbsp;&amp;nbsp;
return mTheAnswer;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; set{&amp;nbsp; mTheAnswer
= value;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Public Property TheAnswer() as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Get&lt;br&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;
Return mTheAnswer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Set (Value
as Integer)&lt;br&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;
mTheAnswer = Value&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Set&lt;br&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;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Property&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;a read-only property...&lt;br&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public int TheAnswer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; get{&amp;nbsp;&amp;nbsp;
return mTheAnswer;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Public ReadOnly Property TheAnswer() as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Get&lt;br&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;
Return mTheAnswer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Property&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;a write-only property...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: public int TheAnswer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; set{&amp;nbsp; mTheAnswer
= value;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Public WriteOnly Property TheAnswer() as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Set (Value
as Integer)&lt;br&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;
mTheAnswer = Value&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Set&lt;br&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;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Property&lt;/font&gt;&lt;/blockquote&gt;VB.NET
needs to be explicity told a property is read- or write-only, C# is happy as long
as there is a get or set -- it figures it out.&lt;br&gt;
&lt;br&gt;
static(Shared) members...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: private static int mANumberEveryoneNeeds;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; public static ANumberEveryoneNeeds&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; get{return &lt;/font&gt;&lt;font color="#0000ff"&gt;mANumberEveryoneNeeds;}&lt;/font&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void ResetTheNumber()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;mANumberEveryoneNeeds
= 0;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;/font&gt; &lt;font color="#008000"&gt;ala VB: Private Shared mANumberEveryonNeeds as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Readonly Shared Property
ANumberEveryoneNeeds() as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Get&lt;br&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;
Return mANumberEveryoneNeeds&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; End Property&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Public Shared Sub ResetTheNumber
()&lt;br&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;
mANumberEveryoneNeeds = 0&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;
&lt;br&gt;
Shared = static.&amp;nbsp; static = Shared. Static members are shared by ALL instances
of a class.&amp;nbsp; The meaning of static is not as immediately a clear as Shared. But
it's not that hard to remember.&lt;br&gt;
&lt;br&gt;
Branching...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: if(SomeVariable == 42)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Answer = "That's
it!";&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; HasWisdom = true;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Answer = "That's
not it.";&lt;br&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;
HasWisdon = false;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //one line syntax&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; if(SomeVariable
== 42)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Answer = "That's
it!";&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Answer = "That's
not it.";&lt;br&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;/font&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: If SomeVariable = 42 Then&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Answer = "That's it!"&lt;br&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; HasWisdom
= True&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Answer = "That's not it."&lt;br&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; HasWisdom
= False&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;There's no Then in C#, the boolean expression is wrapped in parentheses
and the code to execute is within {}. The brackets are not required if the condition
only executes one line.&amp;nbsp; Like most other constructs in VB, the code block ends
with a uniquely named End statement: End If. 
&lt;br&gt;
&lt;br&gt;
Note in C# the == is an evaluation operator, as opposed to the assignment operator
=.&amp;nbsp; In VB = performs both tasks. 
&lt;br&gt;
&lt;br&gt;
What fun is an If statement without boolean logic...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: if(!Page.IsPostBack) //Not operator&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;if(Night
!= Day) //Inequality&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;if(Night
== Day &amp;amp; Pigs.CurrentState == PigState.Flying) // And&lt;/font&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; if(&lt;/font&gt;&lt;font color="#0000ff"&gt;Night
== Day &amp;amp;&amp;amp; Pigs.CurrentState == PigState.Flying&lt;/font&gt;&lt;font color="#0000ff"&gt;)
//Conditional And&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;if(Night
== Day | Pigs.CurrentState == PigState.Flying) // Or&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;if(Night
== Day || Pigs.CurrentState == PigState.Flying) // Conditional Or&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;if(Night
== Day ^ Pigs.CurrentState == PigState.Flying) // Xor&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: If Not Page.IsPostBack Then&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; If Night &amp;lt;&amp;gt; Day Then 'Inequality&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Night = Day And Pigs.CurrentState
= PigState.Flying Then 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000"&gt;If
Night = Day AndAlso Pigs.CurrentState = PigState.Flying Then 'Conditional And&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If Night
= Day Or Pigs.CurrentState = PigState.Flying Then 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000"&gt;If
Night = Day OrElse Pigs.CurrentState = PigState.Flying Then 'Conditional Or&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000"&gt;If
Night = Day Xor Pigs.CurrentState = PigState.Flying Then&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;VB spells everything out, though &amp;lt;&amp;gt; is a unique feature
of the language.&amp;nbsp; The conditional operators AndAlso (&amp;amp;&amp;amp;) and OrElse(||)
are tres useful, they short circuit the code and stop evaluting as soon as the appropriate
condition is met. 
&lt;br&gt;
&lt;br&gt;
And when If Then is isn't enough...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: &lt;/font&gt;&lt;font color="#0000ff"&gt;switch(SelectedPlanet)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&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; case
PlanetValues.Earth:&lt;br&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;
message = "Live there";&lt;br&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;
break;&lt;br&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; case
PlanetValues.Venus:&lt;br&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; case
PlanetValues.Mars:&lt;br&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; message = "Landed there";&lt;br&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; break;&lt;br&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;/font&gt;&lt;font color="#0000ff"&gt;case
PlanetValues.Mercury:&lt;br&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; case
PlanetValues.Jupiter:&lt;br&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; case
PlanetValues.Saturn:&lt;br&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; case
PlanetValues.Uranus:&lt;br&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; case
PlanetValues.Neptune:&lt;br&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; message = "Flew by";&lt;br&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; break;&lt;br&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; case
PlanetValues.Pluto:&lt;br&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; message = "Is it a planet?"&lt;br&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; break;&lt;br&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;
default:&lt;br&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; message = "Never heard of it";&lt;br&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; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Select Case SelectedPlanet&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Case PlanetValues.Earth&lt;br&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;
message = "Live there"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Case PlanetValues.Venus,
PlanetValues.Mars&lt;br&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;
message = "Landed there"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Case PlanetValues.Mercury,
PlanetValues.Jupiter, PlanetValues.Saturn, PlanetValues.Uranus, PlanetValues.Neptune&lt;br&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;
message = "Flew by"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Case PlanetValues.Pluto&lt;br&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;
message = "Is it a planet?"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Case Else&lt;br&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;
message = "Never heard of it"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End Select&lt;/font&gt;&lt;font color="#008000"&gt;&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;In C#, there's only one value per case, but once a supplied value matches
a case, the code will "fall through" until it finds a case that executes code.&amp;nbsp;
All cases that have code must end with a break;. 
&lt;br&gt;
In VB, multiple values can be present on a line, it's also possible to do &lt;a href="http://msdn2.microsoft.com/en-us/library/cy37t14y%28VS.71%29.aspx"&gt;ranges.&lt;/a&gt; The
code cannot fall through in VB, but the extra flexibility for defining case values
makes it unecessary. 
&lt;br&gt;
&lt;br&gt;
For Loops...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: for(int Index = 0; Index &amp;lt; SomeIntegerArray.Length;
Index ++)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&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; Total
+= SomeIntegerArray[Index];&lt;br&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; CallSomeOtherFunction(SomeIntegerArray[Index]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; //A single line For Loop
can be done without the brackets&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;for(int
Index = 0; Index &amp;lt; SomeIntegerArray.Length; Index ++)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;Total
+= SomeIntegerArray[Index];&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: For Index as Integer = 0 to SomeIntegerArray.Length
-1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; CallSomeOtherFunction(SomeIntegerArray(Index))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Next&lt;/font&gt;&lt;/blockquote&gt;
&lt;br&gt;
In C#, {} brackets define what code gets looped, but a single line statement does
not require brackets. Iteration step size is always specified&lt;br&gt;
VB always requires the Next statement.&amp;nbsp; The iteration step size defaults to 1
for VB, to change the iteration step size...&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: for(int Index = 0; Index &amp;lt; SomeIntegerArray.Length;
Index += 2)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&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; Total
+= SomeIntegerArray[Index];&lt;br&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; CallSomeOtherFunction(SomeIntegerArray[Index]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: For Index as Integer = 0 to SomeIntegerArray.Length
-1 Step 2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000"&gt;CallSomeOtherFunction(SomeIntegerArray(Index))&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Next&lt;/font&gt;&lt;/blockquote&gt;To
break out of the loop before it completes...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: for(int Index = 0; Index &amp;lt; SomeIntegerArray.Length;
Index += 2)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&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; Total
+= SomeIntegerArray[Index];&lt;br&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; if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)&lt;br&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;
break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: For Index as Integer = 0 to SomeIntegerArray.Length
-1 Step 2&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If &lt;/font&gt;&lt;font color="#008000"&gt;CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then&lt;br&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;
Exit For&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&gt;
&lt;/font&gt; &lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Next&lt;/font&gt;&lt;/blockquote&gt;break
is used to get out of every kind of loop in C#.&amp;nbsp; The command for exiting a loop
in VB.NET depends on the type of the loop. This can come in handy for nested loops
of different types.&lt;br&gt;
&lt;br&gt;
For each loops...&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: foreach(Universe PossibleUniverse in PossibleUniverses)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&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; if(PossibleUniverse.HasStrongForce)&lt;br&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;br&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;br&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; AddToViableCandidates(PossibleUniverse);&lt;br&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;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: For Each PossibleUniverse as Universe in PossibleUniverses 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If PossibleUniverse.HasStrongForce
Then&lt;br&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;
AddToViableCandidates(PossibleUniverse)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Next&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/blockquote&gt;Ignore the brackets and the for each loops look a lot alike.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Do While Loops...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&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; Total
+= SomeIntegerArray[Index];&lt;br&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; if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)&lt;br&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;
break;&lt;br&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; Index++;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; while(Index &amp;lt; SomeIntegerArray.Length);&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If &lt;/font&gt;&lt;font color="#008000"&gt;CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then&lt;br&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;
Exit Do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&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;
Index += 1&lt;br&gt;
&lt;/font&gt; &lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Loop While
Index &amp;lt; SomeIntegerArray.Length&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Do &lt;/font&gt;&lt;font color="#008000"&gt;While
Index &amp;lt; SomeIntegerArray.Length&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If &lt;/font&gt;&lt;font color="#008000"&gt;CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then&lt;br&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;
Exit Do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Index += 1&lt;br&gt;
&lt;/font&gt; &lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Loop &lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
The do loop in C# always executes at least once.&amp;nbsp; The top version of the VB loop
does as well.&amp;nbsp; While the second version evaluates the condition before executing.
This is the one of the few code structures in VB that doesn't denote it's end using
an End statement (the others being the for and for each loops). If it did it would
look something like this...&lt;br&gt;
&lt;font color="#ff1493"&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'This is not legal syntax -- just what
a Do loop would look like if VB were maddeningly consistent&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Total +=SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Do While Index &amp;lt; SomeIntegerArray.Length&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
Which is just goofy.&lt;br&gt;
&lt;br&gt;
Do Until Loops...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&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; Total
+= SomeIntegerArray[Index];&lt;br&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; if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)&lt;br&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;
break;&lt;br&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; Index++;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; while(Index &amp;lt; SomeIntegerArray.Length);&lt;br&gt;
&lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: Do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If &lt;/font&gt;&lt;font color="#008000"&gt;CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then&lt;br&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;
Exit Do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Index += 1&lt;br&gt;
&lt;/font&gt; &lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Loop Until
Index = SomeIntegerArray.Length&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; Do &lt;/font&gt;&lt;font color="#008000"&gt;Until
Index = SomeIntegerArray.Length&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If &lt;/font&gt;&lt;font color="#008000"&gt;CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then&lt;br&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;
Exit Do&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Index += 1&lt;br&gt;
&lt;/font&gt; &lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Loop &lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt; 
&lt;br&gt;
Wait a second -- there's no &lt;b&gt;do until&lt;/b&gt; in C#. &lt;b&gt;Until&lt;/b&gt; is just the other
side of &lt;b&gt;while&lt;/b&gt;.&amp;nbsp; Instead of executing &lt;b&gt;while&lt;/b&gt; a condition is true,
it executes &lt;b&gt;until&lt;/b&gt; it is true. When moving from VB.NET to C# just use the while
and flip the condition to its opposite. Again the C# loop and the first VB loop execute
at least once.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
And the last loop is the plain old while loop...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: &lt;/font&gt;&lt;font color="#0000ff"&gt;while(Index
&amp;lt; SomeIntegerArray.Length)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; {&lt;br&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; Total
+= SomeIntegerArray[Index];&lt;br&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; if(CallSomeOtherFunction(SomeIntegerArray[Index])
== false)&lt;br&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;
break;&lt;br&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; Index++;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/font&gt;&lt;font color="#0000ff"&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;ala VB: While &lt;/font&gt;&lt;font color="#008000"&gt;Index &amp;lt;
SomeIntegerArray.Length&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;
Total += SomeIntegerArray(Index)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; If &lt;/font&gt;&lt;font color="#008000"&gt;CallSomeOtherFunction(SomeIntegerArray(Index))
= False Then&lt;br&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;
Exit While&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End if&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Index += 1&lt;br&gt;
&lt;/font&gt; &lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End&amp;nbsp;
While 
&lt;br&gt;
&lt;/font&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000"&gt;&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt; While loops in both languages evaluate the condition before executing.&amp;nbsp;
Note the while uses the familiar Exit While to break and the End While to terminate
the loop.&lt;br&gt;
&lt;br&gt;
Finally, a tricky difference -- hooking up event handlers...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#0000ff"&gt;ala C#: &lt;/font&gt;&lt;font color="#0000ff"&gt;SomeButton.Click
+= new ButtonEventHandler(SomeButton_Click);&lt;/font&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#0000ff"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;ala VB: AddHandler SomeButton.Click, AddressOf SomeButton_Click&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 'or directly declare
it&lt;/font&gt;
&lt;br&gt;
&lt;font color="#008000"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Sub SomeButton_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles SomeButton.Click&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;VB lets you hook up the Handler on the event declaration or add the handler
dynamically.&amp;nbsp; C# only allows the dynamic hook.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
I think this post has sufficiently covered 93.7% of commonly encountered code.&amp;nbsp;
I'd cover &lt;a href="http://msdn2.microsoft.com/en-us/library/512aeb7t.aspx"&gt;Generics&lt;/a&gt; (&lt;a href="http://msdn2.microsoft.com/en-us/library/ms379608%28vs.80%29.aspx"&gt;VB
usage)&lt;/a&gt;&amp;nbsp; but I think anyone working with Generics probably doesn't have any
problems reading either language.&lt;br&gt;
&lt;br&gt;
Here are some reference links...&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/6a71f45d.aspx"&gt;C# Operators&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/x53a06bb.aspx"&gt;C# Keywords&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/ksh7h19t%28VS.71%29.aspx"&gt;VB.NET
Keywords&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxgrfLanguageEquivalents.asp"&gt;Language
Equivalents&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
And for the truly lazy or people who have to translate more than 20 lines of code,
there are converters (though you might get some &lt;a href="http://www.vpsw.com/blogbaby/PermaLink,guid,bb634e82-a78f-4fca-9d5d-a63616d70f99.aspx"&gt;interesting
results&lt;/a&gt;) ...&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.tangiblesoftwaresolutions.com/"&gt;Tanglible Software&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx"&gt;Developer
Fusion&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.google.com/search?q=c%23+vb+converter&amp;amp;sourceid=navclient-ff&amp;amp;ie=UTF-8&amp;amp;rlz=1B3GGGL_enUS176US213&amp;amp;aq=t"&gt;Or
Google For More&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
So learn 'em both -- double your code examples, double your employment opportunities
-- double your fun.&lt;br&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=c163aa6c-bbc2-4175-a653-00e46e2de3a1" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,c163aa6c-bbc2-4175-a653-00e46e2de3a1.aspx</comments>
      <category>.NET</category>
      <category>2.0</category>
      <category>Annoyances</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=a02a3798-5e4e-4fef-8cec-5399ccabf2ce</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,a02a3798-5e4e-4fef-8cec-5399ccabf2ce.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,a02a3798-5e4e-4fef-8cec-5399ccabf2ce.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=a02a3798-5e4e-4fef-8cec-5399ccabf2ce</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Sometimes I see a method and say "Where
have you been all my life?"  When it's in code I wrote over a year ago, I have
to say "How did I ever let you go?"  I'm writing this so I don't ever forget
it again and to introduce the most useful class that holds it.<br /><br />
The method in question is quite simple, but very useful...<br /><br /><a href="http://msdn2.microsoft.com/en-us/library/system.io.path.getfilename.aspx">Path.GetFileName(SomeFilePath)</a><br /><br />
It takes a full file path and just returns the File Name and Extension. Very handy
when uploading files or checking URLs.  So useful, I wrote my own version of
the function and put it in the base web page class of my projects.   So
today I am wandering through some code and there it was.  I used it in a method
that I wrote almost 2 years ago and then FORGOT about it. Duh, talk about reinventing
the wheel.  
<br /><br />
And there are more wheels....<br /><br /><a href="http://msdn2.microsoft.com/en-us/library/system.io.path.getfilenamewithoutextension.aspx">Path.GetFileNameWithoutExtension(SomeFilePath)</a><br /><br />
Nice! Saves an IndexOf or Split call to get the goodies.<br /><br /><a href="http://msdn2.microsoft.com/en-us/library/system.io.path.changeextension.aspx">Path.ChangeExtension(SomeFilePath,
NewExtension)</a><br /><br />
Quick change file extension and it makes sure there is a dot between them.<br /><br /><a href="http://msdn2.microsoft.com/en-us/library/system.io.path.getpathroot.aspx">Path.GetPathRoot(SomeFilePath)</a><br /><br />
Gets the other side of the file path.<br /><br />
But the real nice one is this one...<br /><br /><a href="http://msdn2.microsoft.com/en-us/library/system.io.path.combine.aspx">Path.Combine(SomeFilePath1,
SomeFilePath2)</a><br /><br />
This is the one I REALLY wish I knew about.  There are so many things that need
to be checked to join two parts of a path together properly.  Is one of the parts
blank?  Does part 1 end with a path separator, does part 2 start with one? 
This one call replaces 12-15 lines of code.  
<br /><br />
Oy, if I had only remembered this class, it could have saved me a few hours of my
life. Need to investigate the Framework a little more thoroughly in the future.  
<br /><br />
As for the Path class -- she's never leaving my side again.  
<br /><br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=a02a3798-5e4e-4fef-8cec-5399ccabf2ce" /></body>
      <title>We'll Always Have Parameters</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,a02a3798-5e4e-4fef-8cec-5399ccabf2ce.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,a02a3798-5e4e-4fef-8cec-5399ccabf2ce.aspx</link>
      <pubDate>Thu, 15 Mar 2007 02:11:17 GMT</pubDate>
      <description>Sometimes I see a method and say "Where have you been all my life?"&amp;nbsp; When it's in code I wrote over a year ago, I have to say "How did I ever let you go?"&amp;nbsp; I'm writing this so I don't ever forget it again and to introduce the most useful class that holds it.&lt;br&gt;
&lt;br&gt;
The method in question is quite simple, but very useful...&lt;br&gt;
&lt;br&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/system.io.path.getfilename.aspx"&gt;Path.GetFileName(SomeFilePath)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
It takes a full file path and just returns the File Name and Extension. Very handy
when uploading files or checking URLs.&amp;nbsp; So useful, I wrote my own version of
the function and put it in the base web page class of my projects.&amp;nbsp;&amp;nbsp; So
today I am wandering through some code and there it was.&amp;nbsp; I used it in a method
that I wrote almost 2 years ago and then FORGOT about it. Duh, talk about reinventing
the wheel.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
And there are more wheels....&lt;br&gt;
&lt;br&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/system.io.path.getfilenamewithoutextension.aspx"&gt;Path.GetFileNameWithoutExtension(SomeFilePath)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
Nice! Saves an IndexOf or Split call to get the goodies.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/system.io.path.changeextension.aspx"&gt;Path.ChangeExtension(SomeFilePath,
NewExtension)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
Quick change file extension and it makes sure there is a dot between them.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/system.io.path.getpathroot.aspx"&gt;Path.GetPathRoot(SomeFilePath)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
Gets the other side of the file path.&lt;br&gt;
&lt;br&gt;
But the real nice one is this one...&lt;br&gt;
&lt;br&gt;
&lt;a href="http://msdn2.microsoft.com/en-us/library/system.io.path.combine.aspx"&gt;Path.Combine(SomeFilePath1,
SomeFilePath2)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
This is the one I REALLY wish I knew about.&amp;nbsp; There are so many things that need
to be checked to join two parts of a path together properly.&amp;nbsp; Is one of the parts
blank?&amp;nbsp; Does part 1 end with a path separator, does part 2 start with one?&amp;nbsp;
This one call replaces 12-15 lines of code.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
Oy, if I had only remembered this class, it could have saved me a few hours of my
life. Need to investigate the Framework a little more thoroughly in the future.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
As for the Path class -- she's never leaving my side again.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=a02a3798-5e4e-4fef-8cec-5399ccabf2ce" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,a02a3798-5e4e-4fef-8cec-5399ccabf2ce.aspx</comments>
      <category>.NET</category>
      <category>Forgotten Classes</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=3a714537-4f53-46da-af87-d52921f773e7</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=3a714537-4f53-46da-af87-d52921f773e7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Under ASP.NET 1.1, the ASP.NET engine is
not (by default) responsible for the application's image, style sheet, and javascript
files. These are served up directly by IIS. ASP.NET can be made responsible for these
file types by playing with the ISAPI file mappings and maybe creating an HttpHandler
or two.<br /><br />
This changes under ASP.NET 2.0.  The ASP.NET engine has responsibility for all
these file types and is called when a request for one is made. 
<br /><br />
So what?  The files get served, the application works, who cares if IIS or ASP.NET
does the work?<br /><br />
In many applications it wouldn't matter, but what happens if the application has been
secured in web.config like so...<br /><br />
&lt;authorization&gt;<br />
   &lt;deny users="?" /&gt;<br />
&lt;/authorization&gt;<br /><br />
... and an anonymous user tries to access the site and gets redirected to the login
page?<br /><br />
Under 1.1, since IIS was responsible for the css, javascript and image files, it wouldn't
matter -- the page would be served as expected, showing all the images and properly
referencing any stylesheets or script files.<br /><br />
Under 2.0, the anonymous user would see an unstyled page with blank image boxes. Any
javascript calls to referenced files won't work either. Why? Because ASP.NET isn't
going to serve up anything but the login page to an anonymous user -- because that
is what it was told to do.<br /><br />
This is great for security, but can be a little frustrating when you KNOW you put
the right path in for that image, and KNOW that the all h1 elements should be hot
pink  and all you see is an unformatted mess.<br /><br />
Fortunately it is very easy to work around this so the public pages on a secured site
show up properly.  All that needs to be done is to tell the application that
anonymous users are allowed to access the content in certain folders. This can be
done using a <a href="http://msdn2.microsoft.com/en-us/library/b6x6shw7.aspx">location
element</a> or two in the web.config file.  The following one allows anonymous
users to access content in the unsecured_images folder...<br /><br />
&lt;location path="unsecured_images"&gt;<br />
    &lt;system.web&gt;<br />
      &lt;authorization&gt;<br />
        &lt;allow users="*" /&gt;<br />
      &lt;/authorization&gt;<br />
    &lt;/system.web&gt;<br />
  &lt;/location&gt;<br /><br />
That's all there is to it. 
<br /><br /><br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=3a714537-4f53-46da-af87-d52921f773e7" /></body>
      <title>Before You Go Insane...</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</link>
      <pubDate>Thu, 18 Jan 2007 03:29:44 GMT</pubDate>
      <description>Under ASP.NET 1.1, the ASP.NET engine is not (by default) responsible for the application's image, style sheet, and javascript files. These are served up directly by IIS. ASP.NET can be made responsible for these file types by playing with the ISAPI file mappings and maybe creating an HttpHandler or two.&lt;br&gt;
&lt;br&gt;
This changes under ASP.NET 2.0.&amp;nbsp; The ASP.NET engine has responsibility for all
these file types and is called when a request for one is made. 
&lt;br&gt;
&lt;br&gt;
So what?&amp;nbsp; The files get served, the application works, who cares if IIS or ASP.NET
does the work?&lt;br&gt;
&lt;br&gt;
In many applications it wouldn't matter, but what happens if the application has been
secured in web.config like so...&lt;br&gt;
&lt;br&gt;
&amp;lt;authorization&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;deny users="?" /&amp;gt;&lt;br&gt;
&amp;lt;/authorization&amp;gt;&lt;br&gt;
&lt;br&gt;
... and an anonymous user tries to access the site and gets redirected to the login
page?&lt;br&gt;
&lt;br&gt;
Under 1.1, since IIS was responsible for the css, javascript and image files, it wouldn't
matter -- the page would be served as expected, showing all the images and properly
referencing any stylesheets or script files.&lt;br&gt;
&lt;br&gt;
Under 2.0, the anonymous user would see an unstyled page with blank image boxes. Any
javascript calls to referenced files won't work either. Why? Because ASP.NET isn't
going to serve up anything but the login page to an anonymous user -- because that
is what it was told to do.&lt;br&gt;
&lt;br&gt;
This is great for security, but can be a little frustrating when you KNOW you put
the right path in for that image, and KNOW that the all h1 elements should be hot
pink&amp;nbsp; and all you see is an unformatted mess.&lt;br&gt;
&lt;br&gt;
Fortunately it is very easy to work around this so the public pages on a secured site
show up properly.&amp;nbsp; All that needs to be done is to tell the application that
anonymous users are allowed to access the content in certain folders. This can be
done using a &lt;a href="http://msdn2.microsoft.com/en-us/library/b6x6shw7.aspx"&gt;location
element&lt;/a&gt; or two in the web.config file.&amp;nbsp; The following one allows anonymous
users to access content in the unsecured_images folder...&lt;br&gt;
&lt;br&gt;
&amp;lt;location path="unsecured_images"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;system.web&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;authorization&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;allow users="*" /&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/authorization&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/system.web&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/location&amp;gt;&lt;br&gt;
&lt;br&gt;
That's all there is to it. 
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=3a714537-4f53-46da-af87-d52921f773e7" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,3a714537-4f53-46da-af87-d52921f773e7.aspx</comments>
      <category>.NET</category>
      <category>2.0</category>
      <category>2.0 Conversion</category>
      <category>web.config</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=27013c9f-ec59-4762-9569-462a9b6b6653</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=27013c9f-ec59-4762-9569-462a9b6b6653</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Finally! .NET 2.0 has been out for a year.  Finally found the time to move
our <a href="http://www.celadonlabs.com/probeity/login.aspx?demo=true">main application</a> to
2.0. It's been a bit of an adventure.  There are 12 class libraries, 2 server
control assemblies, a service, a web app and various utilities.  Two of the class
libraries are in C++, one managed, one native. The truly insane can read about the <a href="http://community.strongcoders.com/blogs/vpsw/archive/2006/11/14/a-journey-to-c-land.aspx">little
odyssey through those assemblies</a>.  Everything else is written in VB.NET.  
<br /><br />
The VB.NET class libraries converted easily.  The only issue was in the few classes
that performed XSL Transformations where I had to change a couple of deprecated method
calls.  <a href="http://www.vpsw.com/blogbaby/PermaLink,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx">These
were no surprise</a>.  Other than that there were only warnings for untyped functions
or parameters (very naughty, and one of the dangers of working in VB with OPTION STRICT
OFF) and a surprising number of unused local variables.  
<br /><br />
The web application was a lot trickier than anticipated.  There are some <a href="http://msdn2.microsoft.com/en-us/library/ms379586%28VS.80%29.aspx">fundamental
differences</a> between 1.1 and 2.0 web applications. One of the significant changes
is in the coding model.  2.0 makes use of partial classes, so that a single class
can be created from separate files, this cleans some things up.  There are no
longer control declarations in the code-behind file, but it is a change.  
</p>
        <p>
Here is a very <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/conversionissuesasp_net.asp">handy
resource</a> that discusses most of the issues you will run into when converting from
1.1 to 2.0.  
<br /><br />
In the standard out-of-the-box VS2005, the project file for web applications has also
gone the way of the dodo, you create Web Site Projects.  Everything in the project
tree gets put into the application. Fortunately, there is a feature to exclude files,
which you will use. Since the Web Site Project includes ALL the files in
the directory tree, files that you excluded in your 1.1 project will suddenly reappear
like uncompilable ghosts in the 2.0 version. The other annoying "feature" is that
these projects spew forth an assembly for every folder in your application, and couple
of others for good measure, and the files are randomly named.  Hello deployment
fun -- I'm sure there's good reason for this, but it is not intuitively obvious, it
seems friggin' nutty.
</p>
        <p>
This application model had been fine for the smaller projects I had
converted, and I figured I would discover a way to deal with the assembly vomit, so
I pushed on assuming that I was moments away from having a our application working
in 2.0. 
</p>
        <p>
But it was not to be, this web application pushed the Web Site Project model over
the cliff of despair.
</p>
        <p>
The application has around 60 pages, 15 classes and 15 user controls spread
amongst 10 directories. Most of the heavy lifting is done in the underlying libraries. I
didn't think it was that large until I tried to compile it.  In VS 2003, it was
up and running in under a minute, in VS2005 it was 5+ minutes, and the sucker was
crashing every time I changed the base web page class that the pages inherited from. 
I lived with this for about a day, googling while it compiled or restarted, toggling
various settings, swearing and pruning previously exlcuded and unused pages ruthlessly.  
</p>
        <p>
After one seemingly eternal cycle of rebooting, I seriously considered asking
for a quad-core super box or retreating back to 1.1.  I decided to take one
more look around the web for a solution and I stumbled across this <a href="http://www.simple-talk.com/dotnet/asp.net/asp.net-2.0-and-vs-2005---you-win-some,-you-lose-some/">article</a>,
which in turn led me to discover an alternate model to this lunancy, the <a href="http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx">Web
Application Project</a>! It was the old 1.1 compilation model, complete with
a single assembly output -- hooray.  It required some VS update installations
and yet another conversion from my original 1.1 application, but in a few hours I
had a quickly compiling application.  Some testing and a small victory dance
later, and it was time to start ripping out the facacta hand-rolled page templates
and putting in the master pages!
</p>
        <p>
        </p>
        <hr />
        <br />
Just a reminder kids, always use source code control, especially when undertaking
a conversion.  It makes mistakes almost painless and recovery simple! 
<br /><hr size="2" width="100%" /><br /><font color="#ff0000">UPDATE:</font>  MS has shipped the <a href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx">first
service pack for VS 2005</a>. This includes the Web Application Projects. If you have
previously installed the Web Application update, you will have to uninstall it before
installing the service pack.<br /><p></p><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=27013c9f-ec59-4762-9569-462a9b6b6653" /></body>
      <title>Moving On Up to 2.0</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</link>
      <pubDate>Thu, 21 Dec 2006 04:04:59 GMT</pubDate>
      <description>&lt;p&gt;
Finally! .NET 2.0 has been out for a year.&amp;nbsp; Finally found the time&amp;nbsp;to move
our &lt;a href="http://www.celadonlabs.com/probeity/login.aspx?demo=true"&gt;main application&lt;/a&gt; to
2.0. It's been a bit of an adventure.&amp;nbsp; There are 12 class libraries, 2 server
control assemblies, a service, a web app and various utilities.&amp;nbsp; Two of the class
libraries are in C++, one managed, one native. The truly insane can read about the &lt;a href="http://community.strongcoders.com/blogs/vpsw/archive/2006/11/14/a-journey-to-c-land.aspx"&gt;little
odyssey through those assemblies&lt;/a&gt;.&amp;nbsp; Everything else is written in VB.NET.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
The VB.NET class libraries converted easily.&amp;nbsp; The only issue was in the few classes
that performed XSL Transformations where I had to change a couple of deprecated method
calls.&amp;nbsp; &lt;a href="http://www.vpsw.com/blogbaby/PermaLink,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx"&gt;These
were no surprise&lt;/a&gt;.&amp;nbsp; Other than that there were only warnings for untyped functions
or parameters (very naughty, and one of the dangers of working in VB with OPTION STRICT
OFF) and a surprising number of unused local variables.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
The web application was a&amp;nbsp;lot trickier than anticipated.&amp;nbsp; There are some &lt;a href="http://msdn2.microsoft.com/en-us/library/ms379586%28VS.80%29.aspx"&gt;fundamental
differences&lt;/a&gt; between 1.1 and 2.0 web applications. One of the significant changes
is in the coding model.&amp;nbsp; 2.0 makes use of partial classes, so that a single class
can be created from separate files, this cleans some things up.&amp;nbsp; There are no
longer control declarations in the code-behind file, but it is a change.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Here is a very &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/conversionissuesasp_net.asp"&gt;handy
resource&lt;/a&gt; that discusses most of the issues you will run into when converting from
1.1 to 2.0.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
In the standard out-of-the-box VS2005, the project file for web applications has also
gone the way of the dodo, you create Web Site Projects.&amp;nbsp; Everything in the project
tree gets put into the application. Fortunately, there is a feature to exclude files,
which you will use. Since the Web Site Project includes&amp;nbsp;ALL the&amp;nbsp;files in
the directory tree, files that you excluded in your 1.1 project will suddenly reappear
like uncompilable ghosts in the 2.0 version. The other annoying "feature" is that
these projects spew forth an assembly for every folder in your application, and couple
of others for good measure, and the files are randomly named.&amp;nbsp; Hello deployment
fun -- I'm sure there's good reason for this, but it is not intuitively obvious, it
seems friggin' nutty.
&lt;/p&gt;
&lt;p&gt;
This&amp;nbsp;application&amp;nbsp;model&amp;nbsp;had been fine for the smaller projects I had
converted, and I figured I would discover a way to deal with the assembly vomit, so
I pushed on assuming that I was moments away from having a our application working
in 2.0. 
&lt;/p&gt;
&lt;p&gt;
But it was not to be, this web application pushed&amp;nbsp;the Web Site Project model&amp;nbsp;over
the cliff of despair.
&lt;/p&gt;
&lt;p&gt;
The&amp;nbsp;application has around 60 pages, 15 classes&amp;nbsp;and 15 user controls spread
amongst 10 directories.&amp;nbsp;Most of the heavy lifting is done in the underlying libraries.&amp;nbsp;I
didn't think it was that large until I tried to compile it.&amp;nbsp; In VS 2003, it was
up and running in under a minute, in VS2005 it was 5+ minutes, and the sucker was
crashing every time I changed the base web page class that the pages inherited from.&amp;nbsp;
I lived with this for about a day, googling while it compiled or restarted, toggling
various settings, swearing and pruning previously exlcuded and unused pages ruthlessly.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
After one seemingly eternal cycle of rebooting, I&amp;nbsp;seriously considered asking
for a quad-core super box or retreating back to 1.1.&amp;nbsp;&amp;nbsp;I decided to take&amp;nbsp;one
more look around the web&amp;nbsp;for a solution and&amp;nbsp;I stumbled across this &lt;a href="http://www.simple-talk.com/dotnet/asp.net/asp.net-2.0-and-vs-2005---you-win-some,-you-lose-some/"&gt;article&lt;/a&gt;,
which in turn led me to&amp;nbsp;discover an alternate model to this lunancy, the &lt;a href="http://msdn2.microsoft.com/en-us/asp.net/aa336618.aspx"&gt;Web
Application Project&lt;/a&gt;!&amp;nbsp;It was the old 1.1 compilation model, complete with
a single assembly output -- hooray.&amp;nbsp; It required some VS update installations
and yet another conversion from my original 1.1 application, but in a few hours I
had a quickly compiling application.&amp;nbsp; Some testing and&amp;nbsp;a small victory dance
later, and it was time to start ripping out the facacta hand-rolled page templates
and putting in the master pages!
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;hr&gt;
&lt;br&gt;
Just a reminder kids, always use source code control, especially when undertaking
a conversion.&amp;nbsp; It makes mistakes almost painless and recovery simple! 
&lt;br&gt;
&lt;hr size="2" width="100%"&gt;
&lt;br&gt;
&lt;font color="#ff0000"&gt;UPDATE:&lt;/font&gt;&amp;nbsp; MS has shipped the &lt;a href="http://msdn.microsoft.com/vstudio/support/vs2005sp1/default.aspx"&gt;first
service pack for VS 2005&lt;/a&gt;. This includes the Web Application Projects. If you have
previously installed the Web Application update, you will have to uninstall it before
installing the service pack.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=27013c9f-ec59-4762-9569-462a9b6b6653" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,27013c9f-ec59-4762-9569-462a9b6b6653.aspx</comments>
      <category>.NET</category>
      <category>2.0</category>
      <category>2.0 Conversion</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=5543e4c2-771b-47c2-a8f2-80f820462f46</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,5543e4c2-771b-47c2-a8f2-80f820462f46.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,5543e4c2-771b-47c2-a8f2-80f820462f46.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=5543e4c2-771b-47c2-a8f2-80f820462f46</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Time tramples on and those .NET 1.1 applications
that were shiny and new just a few years ago are probably beginning to show their
age.  Improvements and refinements in every application or class library have
probably left behind a goodly number of dead and dying methods, or even whole classes. 
This is probably even more true of 1.1 applications that were ported to 2.0 and since
refactored to take advantage of new .NET features.  
<br /><br />
While ripping out all these methods before some newbie team member (or forgetful old
hand) accidentally uses one would be ideal, this is not always a practical solution.
But there is an easy way to warn off developers while planning for eventual refactoring,
the <a href="http://msdn2.microsoft.com/en-us/library/system.obsoleteattribute.aspx">Obsolete
Attribute</a>.<br /><br />
Marking a method, property, field, class or interface with the Obsolete Attribute
will generate a compiler warning, and Visual Studio will clearly mark each offending
use of the "soon" to be removed member.  Best of all, it easy is to use.  
<br /><br />
In C#...<br /><blockquote><font color="#000080" face="Courier New">[Obsolete("This method has been
replaced by ReallyUsefulMethod.")]<br />
public void OnceUsefulMethod(){</font><br /><pre class="code" id="ctl00_LibFrame_ctl13CSharp" space="preserve"></pre></blockquote><br />
ala VB.NET (don't forget the line continuation)...<br /><blockquote><font color="#000080" face="Courier New">&lt;Obsolete("This method has
been replaced by ReallyUsefulMethod.")&gt; _</font><br /><font color="#000080" face="Courier New">Public Sub OnceUsefulMethod()</font><br /><pre class="code" id="ctl00_LibFrame_ctl13CSharp" space="preserve"></pre></blockquote><br />
That's all there is to it. If it's called any place, a compiler warning will be generated,
and Intellisense will also display its impending doom.<br /><br />
If for some reason, the method needs to be taken out of use immediately (for a security
concern, etc.) , the Obsolete Attribute can also generate a compiler error using the
code below.  The second argument to the constructor if set=true will generate
an error instead of a warning.<br /><br />
In C#...<br /><blockquote><font color="#000080" face="Courier New">[Obsolete("This method has been
replaced by ReallyUsefulMethod.", true)]<br />
public void OnceUsefulMethod(){</font><br /></blockquote><br />
ala VB.NET...<br /><blockquote><font color="#000080" face="Courier New">&lt;Obsolete("This method has
been replaced by ReallyUsefulMethod.", True)&gt; _</font><br /><font color="#000080" face="Courier New">Public Sub OnceUsefulMethod(){</font><br /><pre class="code" id="ctl00_LibFrame_ctl13CSharp" space="preserve"><br /></pre></blockquote>Using this attribute is also a quick and dirty way to find out
all the places in an application a particular code element is being used.  Compile
the application they'll all be nicely listed in the task list.<br /><br />
The Obsolete Attribute -- an easy to use, graceful first step in pruning and refactoring
-- try it today!<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=5543e4c2-771b-47c2-a8f2-80f820462f46" /></body>
      <title>Stop Using This!</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,5543e4c2-771b-47c2-a8f2-80f820462f46.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,5543e4c2-771b-47c2-a8f2-80f820462f46.aspx</link>
      <pubDate>Thu, 07 Sep 2006 14:14:07 GMT</pubDate>
      <description>Time tramples on and those .NET 1.1 applications that were shiny and new just a few years ago are probably beginning to show their age.&amp;nbsp; Improvements and refinements in every application or class library have probably left behind a goodly number of dead and dying methods, or even whole classes.&amp;nbsp; This is probably even more true of 1.1 applications that were ported to 2.0 and since refactored to take advantage of new .NET features.&amp;nbsp; &lt;br&gt;
&lt;br&gt;
While ripping out all these methods before some newbie team member (or forgetful old
hand) accidentally uses one would be ideal, this is not always a practical solution.
But there is an easy way to warn off developers while planning for eventual refactoring,
the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.obsoleteattribute.aspx"&gt;Obsolete
Attribute&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Marking a method, property, field, class or interface with the Obsolete Attribute
will generate a compiler warning, and Visual Studio will clearly mark each offending
use of the "soon" to be removed member.&amp;nbsp; Best of all, it easy is to use.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
In C#...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;[Obsolete("This method has been
replaced by ReallyUsefulMethod.")]&lt;br&gt;
public void OnceUsefulMethod(){&lt;/font&gt;
&lt;br&gt;
&lt;pre class="code" id="ctl00_LibFrame_ctl13CSharp" space="preserve"&gt;&lt;/pre&gt;&lt;/blockquote&gt;
&lt;br&gt;
ala VB.NET (don't forget the line continuation)...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;lt;Obsolete("This method has
been replaced by ReallyUsefulMethod.")&amp;gt; _&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;Public Sub OnceUsefulMethod()&lt;/font&gt;
&lt;br&gt;
&lt;pre class="code" id="ctl00_LibFrame_ctl13CSharp" space="preserve"&gt;&lt;/pre&gt;&lt;/blockquote&gt;
&lt;br&gt;
That's all there is to it. If it's called any place, a compiler warning will be generated,
and Intellisense will also display its impending doom.&lt;br&gt;
&lt;br&gt;
If for some reason, the method needs to be taken out of use immediately (for a security
concern, etc.) , the Obsolete Attribute can also generate a compiler error using the
code below.&amp;nbsp; The second argument to the constructor if set=true will generate
an error instead of a warning.&lt;br&gt;
&lt;br&gt;
In C#...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;[Obsolete("This method has been
replaced by ReallyUsefulMethod.", true)]&lt;br&gt;
public void OnceUsefulMethod(){&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
ala VB.NET...&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;lt;Obsolete("This method has
been replaced by ReallyUsefulMethod.", True)&amp;gt; _&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;Public Sub OnceUsefulMethod(){&lt;/font&gt;
&lt;br&gt;
&lt;pre class="code" id="ctl00_LibFrame_ctl13CSharp" space="preserve"&gt;
&lt;br&gt;
&lt;/pre&gt;&lt;/blockquote&gt;Using this attribute is also a quick and dirty way to find out
all the places in an application a particular code element is being used.&amp;nbsp; Compile
the application they'll all be nicely listed in the task list.&lt;br&gt;
&lt;br&gt;
The Obsolete Attribute -- an easy to use, graceful first step in pruning and refactoring
-- try it today!&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=5543e4c2-771b-47c2-a8f2-80f820462f46" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,5543e4c2-771b-47c2-a8f2-80f820462f46.aspx</comments>
      <category>.NET</category>
      <category>Attributes</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=bdc25d15-1d36-44ea-bdc1-f997a74cc740</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,bdc25d15-1d36-44ea-bdc1-f997a74cc740.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,bdc25d15-1d36-44ea-bdc1-f997a74cc740.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=bdc25d15-1d36-44ea-bdc1-f997a74cc740</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Just because an application is developed
in .NET doesn't make it object oriented.<br /><br />
It might have classes.<br /><br />
It might have interfaces.<br /><br />
It might have methods.<br /><br />
It still is a mass of spaghetti code, with some objects thrown in to act as meatballs. 
<br /><br />
It never ceases to amaze me what lengths developers will go to to turn .NET into a
overwrought scripting language, instead of harnessing some simple OOP principles to
make their code and their lives simpler.<br /><br />
So, today we are going to talk about <a href="http://atomicobject.com/training/training-material/oo-notes/modularity-and-encapsulation.page">Encapsulation</a>.
Yes, I have spent the last two weeks ripping through an app that had objects, but
frequently didn't use them as much more than fancy structures.  And, yes, I will
rant a little bit (more).<br /><br />
Encapsulation is probably the simplest OOP concept to grasp, and it should be the
easiest to implement.  A developer does not need to understand class factories,
inheritance or polymorphism to develop encapsulated classes.  A desire for clean
interfaces coupled with an abhorrence for writing the same code twice will lead naturally
to encapsulation.<br /><br />
Yet, this well-known tool of code reuse, is often left unloved and dusty, next to
the once-cracked <a href="http://www.amazon.com/gp/product/0201633612/sr=8-2/qid=1148011183/ref=pd_bbs_2/104-4589587-2444704?%5Fencoding=UTF8">Gang
of Four OOP bible</a>. 
<br /><br />
I like to think of Encapsulation as empowering an object.  It allows the object
to say, "This is what I do. This is what I expect.  Don't tell me how to do my
job, just give me what I need and let me do it."<br /><br />
Simple, no?  You'd think so, but it is clearly not a universal practice. 
<br /><br />
Here is an object.  What it does really doesn't matter for this discussion. 
It has two ways of being populated -- one when it is first created, another for when
it is  reconstituted from the database. It has two consctructors. This is a very
common situation.  
<br /><br /><blockquote><font color="#ff0000" face="Courier New">public class SomeEntity{</font><br /><br /><font color="#ff0000" face="Courier New">    //Constructor for new
instance</font><br /><font color="#ff0000" face="Courier New">     public SomeEntity(string
Name, string ANeededValue, int AnotherNeededValue){...}</font><br /><font color="#ff0000" face="Courier New">     </font><br /><font color="#ff0000" face="Courier New">    //Constructor for a retrieved
instance</font><br /><font color="#ff0000" face="Courier New">     public SomeEntity(int
ID, string Name, XmlDocument TheReasonForTheObject){...} 
<br /><br />
    //Members<br />
    private string mName;<br />
    //...<br /></font><br /><font color="#ff0000" face="Courier New">    //Properties, Methods,
Etc.<br /><br />
    public void DoSomethingImportant(){...}<br /><br />
    public string Name{<br />
       { get{return mName;}<br />
    }<br />
    //...<br /></font><font color="#ff0000" face="Courier New">}</font><br /></blockquote><br />
Now, I don't have a problem with the first constructor -- at least there is one, this
actually demonstrates an important bit of encapsulation: controlling how the object
is instantiated.  The constructor gives a way to tell the world,  "This
is what I need to start properly!"<br /><br />
For the free-for-all that can result without encapsulated instantiation, here's the
same object sans a defined constructor...<br /><br /><blockquote><font color="#ff0000" face="Courier New">public class SomeEntity{</font><br /><br />
       <font color="#ff0000" face="Courier New">//default
constructor</font><br />
       <font color="#ff0000" face="Courier New">public
SomeEntity(){}</font><br /><font color="#ff0000" face="Courier New">   </font><br /><font color="#ff0000" face="Courier New">     //Members</font><br /><font color="#ff0000" face="Courier New">     public string Name;<br />
    public string ANeededValue;<br />
    public int AnotherNeededValue;<br />
    
<br />
    </font><font color="#ff0000" face="Courier New">//Properties, Methods,
Etc....<br /></font><font color="#ff0000" face="Courier New">    public void DoSomethingImportant(){...}</font><br /><font color="#ff0000" face="Courier New"></font><font color="#ff0000" face="Courier New"></font><br /><font color="#ff0000" face="Courier New"></font><font color="#ff0000" face="Courier New">}</font><br /></blockquote><br />
What's required to make sure an instance of this object works properly?  The
developer's dilligence, memory and typing skills.  Everywhere the object is created,
the developer must remember to type four lines of code -- just to get the object in
a state where it is minimally functional.<br /><br /><blockquote><font color="#ff0000" face="Courier New">SomeEntity AnObjectINeed = new
SomeEntity();<br />
AnObjectINeed.Name = "Fred";<br /></font><font color="#ff0000" face="Courier New">AnObjectINeed.ANeededValue = "Tuesday";<br /></font><font color="#ff0000" face="Courier New">AnObjectINeed.AnotherNeededValue =
789;</font><br /><font color="#ff0000" face="Courier New"></font></blockquote><br />
Forget to supply a value -- oops, error. What's missing?  Hope the exception
message is clear and go hunting. It is bad enough that this code will be cut-and-pasted
willy-nilly every time the object is needed, but what is worse is the maintenance
implication.  Things change, the object needs an additonal value to work properly....<br /><br /><blockquote><font color="#ff0000" face="Courier New">public class SomeEntity{</font><br /><br /><font color="#ff0000" face="Courier New">   </font><br /><font color="#ff0000" face="Courier New">     //Members</font><br /><font color="#ff0000" face="Courier New">     public string Name;</font><br /><font color="#ff0000" face="Courier New">     public string ANeededValue;</font><br /><font color="#ff0000" face="Courier New">     public int AnotherNeededValue;<br />
    public DateTime OoopsForgotThis;<br /></font><font color="#ff0000" face="Courier New">     </font><br /><font color="#ff0000" face="Courier New">     </font><font color="#ff0000" face="Courier New">//Properties,
Methods, Etc....</font><br /><font color="#ff0000" face="Courier New"></font><font color="#ff0000" face="Courier New">   
public void DoSomethingImportant(){...}</font><br /><font color="#ff0000" face="Courier New"></font><br /><font color="#ff0000" face="Courier New"></font><font color="#ff0000" face="Courier New">}</font><br /></blockquote><br />
Hmmm, what happens now? The object won't work without the new value, but the application
still compiles.  The developer must hunt for EVERY creation of the object and
add another line of code, and then clean up the inevitable bugs when he misses a few.<br /><br />
Using a defined constructor avoids this problem.<br /><br /><font color="#ff0000" face="Courier New">    //Constructor for new
instance</font><br /><font color="#ff0000" face="Courier New">     public SomeEntity(string
Name, string ANeededValue, int AnotherNeededValue, </font><font color="#ff0000" face="Courier New">DateTime
OoopsForgotThis</font><font color="#ff0000" face="Courier New">){...}</font><br /><br />
The application won't compile now. All the places the code needs to be changed will
be listed, they don't have to be hunted for.  Once the changes have been made
and the app compiles, the object will always have what it needs to do its job.<br /><br />
Pardon the long aside, and let me finally return to what bothered me about the second
constructor in the example above...<br /><br /><blockquote><font color="#ff0000" face="Courier New">//Constructor for a retrieved
instance</font><br /><font color="#ff0000" face="Courier New">  public SomeEntity(int ID, string Name,
XmlDocument TheReasonForTheObject){...} </font><br /></blockquote><br />
What bothers me here is a subtle, but more troubling, lack of encapsulation related
to this constructor.  
<br /><br />
In order to call this constructor, three parameters must be supplied, an ID, a name
and an XMLDocument. Now, where are these values stored? In a database record. 
They are retrieved via a stored procedure call using the entity's ID, which is a unique
integer value.  
<br /><br /><b>A UNIQUE value.</b><br /><br />
The ID is unique and possesses all the object needs to know to reconstitute itself. 
Why then, are the other two values needed in the constructor?<br /><br />
They're NOT!<br /><br />
Why are they there?  
<br /><br />
I have no friggin' clue.  But this is part of the foo I've been fighting for
the last few weeks. There are 5 or 6 lines of database-related code that precede every
use of this constructor, along with the creation of an XmlDocument object from its
string respresentation.  That's 8 lines of code repeated each time the object
is recreated from the database, all of which SHOULD have been placed in the object,
so it could have populated itself.<br /><br />
But that's not all?  What is controlling whether or not:<br />
1) The name and XML document supplied are actually related to the supplied ID?<br />
2) The XMLDocument has the proper schema the object expects?<br /><br />
The memory, diligence and typing skills of the developer.  In other words, NO
ONE!  
<br /><br />
By writing the object so it controls its own data retrieval, these problems are avoided.
The object saved (or should have saved -- don't get me started) its own data and can
be fairly confident it is getting the same information back -- in proper form.  
<br /><br /><blockquote><font color="#ff0000" face="Courier New">//Constructor for a retrieved
instance</font><br /><font color="#ff0000" face="Courier New">public SomeEntity(int ID){...} </font><br /></blockquote>The object is empowered, it controls its data, it works properly. 
It can be used in code without requiring 8 supporting lines of code to be written
each time.  
<br /><br />
Why?  
<br /><br />
It's encapsulated!<br /><br />
Want to make the app work when its disconnected and need to store the object in a
local Access database?  No problem, change the storage and retrieval code <b>in
the object</b>.  The rest of the app doesn't know and doesn't care how or where
the object data is stored.  All it knows and cares about is that if it saved
a SomeEntity object with a unique ID = 1776, that when this code is called...<br /><br />
    <font color="#ff0000" face="Courier New">SomeEntity AnObjectINeed
= new SomeEntity(1776);</font><br /><br />
It will get back a SomeEntity object with an ID = 1776 and the proper XMLDocument. 
<br /><br />
An object born ready to do what it is supposed to do. 
<br /><br />
What's hard about that?<br /><br />
Really?<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=bdc25d15-1d36-44ea-bdc1-f997a74cc740" /></body>
      <title>Encapsulate For Fun and Profit</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,bdc25d15-1d36-44ea-bdc1-f997a74cc740.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,bdc25d15-1d36-44ea-bdc1-f997a74cc740.aspx</link>
      <pubDate>Fri, 19 May 2006 03:35:28 GMT</pubDate>
      <description>Just because an application is developed in .NET doesn't make it object oriented.&lt;br&gt;
&lt;br&gt;
It might have classes.&lt;br&gt;
&lt;br&gt;
It might have interfaces.&lt;br&gt;
&lt;br&gt;
It might have methods.&lt;br&gt;
&lt;br&gt;
It still is a mass of spaghetti code, with some objects thrown in to act as meatballs. 
&lt;br&gt;
&lt;br&gt;
It never ceases to amaze me what lengths developers will go to to turn .NET into a
overwrought scripting language, instead of harnessing some simple OOP principles to
make their code and their lives simpler.&lt;br&gt;
&lt;br&gt;
So, today we are going to talk about &lt;a href="http://atomicobject.com/training/training-material/oo-notes/modularity-and-encapsulation.page"&gt;Encapsulation&lt;/a&gt;.
Yes, I have spent the last two weeks ripping through an app that had objects, but
frequently didn't use them as much more than fancy structures.&amp;nbsp; And, yes, I will
rant a little bit (more).&lt;br&gt;
&lt;br&gt;
Encapsulation is probably the simplest OOP concept to grasp, and it should be the
easiest to implement.&amp;nbsp; A developer does not need to understand class factories,
inheritance or polymorphism to develop encapsulated classes.&amp;nbsp; A desire for clean
interfaces coupled with an abhorrence for writing the same code twice will lead naturally
to encapsulation.&lt;br&gt;
&lt;br&gt;
Yet, this well-known tool of code reuse, is often left unloved and dusty, next to
the once-cracked &lt;a href="http://www.amazon.com/gp/product/0201633612/sr=8-2/qid=1148011183/ref=pd_bbs_2/104-4589587-2444704?%5Fencoding=UTF8"&gt;Gang
of Four OOP bible&lt;/a&gt;. 
&lt;br&gt;
&lt;br&gt;
I like to think of Encapsulation as empowering an object.&amp;nbsp; It allows the object
to say, "This is what I do. This is what I expect.&amp;nbsp; Don't tell me how to do my
job, just give me what I need and let me do it."&lt;br&gt;
&lt;br&gt;
Simple, no?&amp;nbsp; You'd think so, but it is clearly not a universal practice. 
&lt;br&gt;
&lt;br&gt;
Here is an object.&amp;nbsp; What it does really doesn't matter for this discussion.&amp;nbsp;
It has two ways of being populated -- one when it is first created, another for when
it is&amp;nbsp; reconstituted from the database. It has two consctructors. This is a very
common situation.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;public class SomeEntity{&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Constructor for new
instance&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public SomeEntity(string
Name, string ANeededValue, int AnotherNeededValue){...}&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Constructor for a retrieved
instance&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public SomeEntity(int
ID, string Name, XmlDocument TheReasonForTheObject){...} 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Members&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; private string mName;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //...&lt;br&gt;
&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Properties, Methods,
Etc.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void DoSomethingImportant(){...}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; { get{return mName;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //...&lt;br&gt;
&lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;}&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
Now, I don't have a problem with the first constructor -- at least there is one, this
actually demonstrates an important bit of encapsulation: controlling how the object
is instantiated.&amp;nbsp; The constructor gives a way to tell the world,&amp;nbsp; "This
is what I need to start properly!"&lt;br&gt;
&lt;br&gt;
For the free-for-all that can result without encapsulated instantiation, here's the
same object sans a defined constructor...&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;public class SomeEntity{&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ff0000" face="Courier New"&gt;//default
constructor&lt;/font&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ff0000" face="Courier New"&gt;public
SomeEntity(){}&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Members&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public string ANeededValue;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public int AnotherNeededValue;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;//Properties, Methods,
Etc....&lt;br&gt;
&lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void DoSomethingImportant(){...}&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;}&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt; 
&lt;br&gt;
What's required to make sure an instance of this object works properly?&amp;nbsp; The
developer's dilligence, memory and typing skills.&amp;nbsp; Everywhere the object is created,
the developer must remember to type four lines of code -- just to get the object in
a state where it is minimally functional.&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;SomeEntity AnObjectINeed = new
SomeEntity();&lt;br&gt;
AnObjectINeed.Name = "Fred";&lt;br&gt;
&lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;AnObjectINeed.ANeededValue = "Tuesday";&lt;br&gt;
&lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;AnObjectINeed.AnotherNeededValue =
789;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&lt;/font&gt; &lt;/blockquote&gt; 
&lt;br&gt;
Forget to supply a value -- oops, error. What's missing?&amp;nbsp; Hope the exception
message is clear and go hunting. It is bad enough that this code will be cut-and-pasted
willy-nilly every time the object is needed, but what is worse is the maintenance
implication.&amp;nbsp; Things change, the object needs an additonal value to work properly....&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;public class SomeEntity{&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; &lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Members&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; public string ANeededValue;&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; public int AnotherNeededValue;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public DateTime OoopsForgotThis;&lt;br&gt;
&lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;//Properties,
Methods, Etc....&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
public void DoSomethingImportant(){...}&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt; &lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;}&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt; 
&lt;br&gt;
Hmmm, what happens now? The object won't work without the new value, but the application
still compiles.&amp;nbsp; The developer must hunt for EVERY creation of the object and
add another line of code, and then clean up the inevitable bugs when he misses a few.&lt;br&gt;
&lt;br&gt;
Using a defined constructor avoids this problem.&lt;br&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Constructor for new
instance&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public SomeEntity(string
Name, string ANeededValue, int AnotherNeededValue, &lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;DateTime
OoopsForgotThis&lt;/font&gt;&lt;font color="#ff0000" face="Courier New"&gt;){...}&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
The application won't compile now. All the places the code needs to be changed will
be listed, they don't have to be hunted for.&amp;nbsp; Once the changes have been made
and the app compiles, the object will always have what it needs to do its job.&lt;br&gt;
&lt;br&gt;
Pardon the long aside, and let me finally return to what bothered me about the second
constructor in the example above...&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;//Constructor for a retrieved
instance&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;&amp;nbsp; public SomeEntity(int ID, string Name,
XmlDocument TheReasonForTheObject){...} &lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
What bothers me here is a subtle, but more troubling, lack of encapsulation related
to this constructor.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
In order to call this constructor, three parameters must be supplied, an ID, a name
and an XMLDocument. Now, where are these values stored? In a database record.&amp;nbsp;
They are retrieved via a stored procedure call using the entity's ID, which is a unique
integer value.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&lt;b&gt;A UNIQUE value.&lt;/b&gt;
&lt;br&gt;
&lt;br&gt;
The ID is unique and possesses all the object needs to know to reconstitute itself.&amp;nbsp;
Why then, are the other two values needed in the constructor?&lt;br&gt;
&lt;br&gt;
They're NOT!&lt;br&gt;
&lt;br&gt;
Why are they there?&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
I have no friggin' clue.&amp;nbsp; But this is part of the foo I've been fighting for
the last few weeks. There are 5 or 6 lines of database-related code that precede every
use of this constructor, along with the creation of an XmlDocument object from its
string respresentation.&amp;nbsp; That's 8 lines of code repeated each time the object
is recreated from the database, all of which SHOULD have been placed in the object,
so it could have populated itself.&lt;br&gt;
&lt;br&gt;
But that's not all?&amp;nbsp; What is controlling whether or not:&lt;br&gt;
1) The name and XML document supplied are actually related to the supplied ID?&lt;br&gt;
2) The XMLDocument has the proper schema the object expects?&lt;br&gt;
&lt;br&gt;
The memory, diligence and typing skills of the developer.&amp;nbsp; In other words, NO
ONE!&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
By writing the object so it controls its own data retrieval, these problems are avoided.
The object saved (or should have saved -- don't get me started) its own data and can
be fairly confident it is getting the same information back -- in proper form.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;//Constructor for a retrieved
instance&lt;/font&gt;
&lt;br&gt;
&lt;font color="#ff0000" face="Courier New"&gt;public SomeEntity(int ID){...} &lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;The object is empowered, it controls its data, it works properly.&amp;nbsp;
It can be used in code without requiring 8 supporting lines of code to be written
each time.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
Why?&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
It's encapsulated!&lt;br&gt;
&lt;br&gt;
Want to make the app work when its disconnected and need to store the object in a
local Access database?&amp;nbsp; No problem, change the storage and retrieval code &lt;b&gt;in
the object&lt;/b&gt;.&amp;nbsp; The rest of the app doesn't know and doesn't care how or where
the object data is stored.&amp;nbsp; All it knows and cares about is that if it saved
a SomeEntity object with a unique ID = 1776, that when this code is called...&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#ff0000" face="Courier New"&gt;SomeEntity AnObjectINeed
= new SomeEntity(1776);&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
It will get back a SomeEntity object with an ID = 1776 and the proper XMLDocument. 
&lt;br&gt;
&lt;br&gt;
An object born ready to do what it is supposed to do. 
&lt;br&gt;
&lt;br&gt;
What's hard about that?&lt;br&gt;
&lt;br&gt;
Really?&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=bdc25d15-1d36-44ea-bdc1-f997a74cc740" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,bdc25d15-1d36-44ea-bdc1-f997a74cc740.aspx</comments>
      <category>.NET</category>
      <category>Good Practices</category>
      <category>OOP</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=bb634e82-a78f-4fca-9d5d-a63616d70f99</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,bb634e82-a78f-4fca-9d5d-a63616d70f99.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,bb634e82-a78f-4fca-9d5d-a63616d70f99.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=bb634e82-a78f-4fca-9d5d-a63616d70f99</wfw:commentRss>
      <title>Plumbing The Depths of the .NET Framework</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,bb634e82-a78f-4fca-9d5d-a63616d70f99.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,bb634e82-a78f-4fca-9d5d-a63616d70f99.aspx</link>
      <pubDate>Sat, 15 Apr 2006 03:53:33 GMT</pubDate>
      <description>Saw a strange method call tonight while answering a post...&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;&lt;span class="q"&gt;System.Threading.Interlocked&lt;wbr&gt;.Increment(i)&lt;/span&gt;&lt;/font&gt;
&lt;br&gt;
&lt;span class="q"&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span class="q"&gt;
&lt;br&gt;
It was in a simple loop, and it turns out it was generated by a code converter (C#
to VB.NET) so the poster didn't know what it was for (curiosity is far too lacking
in this world, but that's a rant for another day).&amp;nbsp; Fortunately, like every other
of the 7-gazillion methods in the .NET framework, if you know it's name you can &lt;a href="http://msdn2.microsoft.com/en-us/library/system.threading.interlocked.increment%28VS.80%29.aspx"&gt;look
it up very easily&lt;/a&gt;. Ah, it is a thread-safe incrementer for use on shared variables.
It ensures that the value is updated and read in an atomic transaction, in other words,
other threads won't increment it as well before it is read. There is no need to use
it on a local variable, but it is a potentially handy tool found in the &lt;a href="http://msdn2.microsoft.com/en-us/library/5kczs5b5%28VS.80%29.aspx"&gt;Interlocked
class&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Now, about the only time I can think you would use this would be if you had a method
that provided a unique integer ID throughout an application.&amp;nbsp; I personally let
SQL Server handle its own ids.&amp;nbsp; But if you don't want to use IDENTITY in SQL
or aren't using a database engine to store your data, this is a handy thing to have.&amp;nbsp;
It also existed in&amp;nbsp; version 1.0 of the framework, so its not something new, but
its not something you'd use everyday, which raises two related questions:&lt;br&gt;
&lt;br&gt;
1) What facacta code converter turns a simple for loop into something so arcane?&lt;br&gt;
or&lt;br&gt;
2) is this call used under the covers of every single loop?&lt;br&gt;
&lt;br&gt;
Ah, &lt;a href="http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx"&gt;found&amp;nbsp;the
suspected converter&lt;/a&gt;&amp;nbsp;on the first try. Thank you Google.&lt;br&gt;
&lt;br&gt;
It turns this simple loop 
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt; &lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;&lt;span class="q"&gt;for(int
i=0;i&amp;lt;10;i++)&lt;/span&gt;
&lt;br&gt;
&lt;span class="q"&gt;{&lt;/span&gt;
&lt;br&gt;
&lt;span class="q"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(i);&lt;/span&gt;
&lt;br&gt;
&lt;span class="q"&gt;}&lt;/span&gt;&lt;/font&gt;
&lt;br&gt;
&lt;span class="q"&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;span class="q"&gt;
&lt;br&gt;
into&lt;br&gt;
&lt;br&gt;
&lt;/span&gt; &lt;blockquote&gt;&lt;font color="#ff0000" face="Courier New"&gt;&lt;code&gt;Dim i As Integer
= 0 
&lt;br&gt;
While i &amp;lt; 10 
&lt;br&gt;
&lt;code &amp;nbsp;Debug.WriteLine(i) &lt;br&gt;&amp;nbsp;System.Math.Min(System.Threading.Interlocked.Increment(i),i-1) 
&lt;br&gt;
End While&lt;/code&gt;
&lt;/font&gt;
&lt;br&gt;
&lt;code class="pre"&gt;&lt;/code&gt;&lt;/blockquote&gt; 
&lt;p&gt;
&lt;code class="pre"&gt;&lt;font face="Arial"&gt;Why not?&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font color="#ff0000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font face="Courier New"&gt;Dim i as Integer&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; For i = 0 to 9&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; Debug.WriteLine(i)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;/font&gt;&lt;/font&gt;
&lt;br&gt;
&lt;font face="Arial"&gt;&lt;/font&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code class="pre"&gt;&lt;font face="Arial"&gt;Or even&lt;/font&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; 
&lt;p&gt;
&lt;code class="pre"&gt;&lt;font face="Arial"&gt;&lt;font color="#ff0000"&gt;&lt;font face="Courier New"&gt;Dim
i As Integer = 0 
&lt;br&gt;
&lt;code class="pre"&gt;While i &amp;lt; 10 &lt;/code&gt;&lt;/font&gt;
&lt;br&gt;
&lt;code class="pre"&gt;&amp;nbsp;Debug.WriteLine(i)&amp;nbsp;&lt;/code&gt;
&lt;br&gt;
&lt;code class="pre"&gt;&amp;nbsp;i = i + 1&amp;nbsp;&lt;/code&gt;
&lt;br&gt;
&lt;code class="pre"&gt;End While&lt;/code&gt;&lt;/font&gt;
&lt;br&gt;
&lt;/font&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;code class="pre"&gt;&lt;font face="Arial"&gt;Of course, this could be what is happening under
the covers anyway.&amp;nbsp; Why this would be so, I don't have the foggiest.&amp;nbsp; Let's
see if we can find out.&lt;/font&gt;&lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
As you probably&amp;nbsp;know, when you compile a .NET app, it gets&amp;nbsp;turned into &lt;a href="http://msdn2.microsoft.com/en-us/library/c5tkafs1%28VS.80%29.aspx"&gt;MSIL&lt;/a&gt; (Microsoft
Intermediate Language) code, not to machine code (the JIT&amp;nbsp;handles that when you
run the app).&amp;nbsp;There is a tool that let's you look at this language if you are
so inclined, the &lt;a href="http://msdn2.microsoft.com/en-us/library/f7dy01k1%28VS.80%29.aspx"&gt;MSIL
Disassembler&lt;/a&gt;.&amp;nbsp; Being so inclined today, let's see what our for loop looks
like in MSIL (the // are comments in the MSIL that indicate the original source code)...
&lt;/p&gt;
&lt;blockquote dir="ltr" style="margin-right: 0px;"&gt; 
&lt;p&gt;
&lt;font color="#ff0000" face="Courier New"&gt;//000028: &amp;nbsp;&amp;nbsp;&amp;nbsp;for(int i = 0;
i&amp;lt;10; i++)&lt;br&gt;
&amp;nbsp; IL_0000:&amp;nbsp; ldc.i4.0&lt;br&gt;
&amp;nbsp; IL_0001:&amp;nbsp; stloc.0&lt;br&gt;
&amp;nbsp; IL_0002:&amp;nbsp; br.s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IL_0013&lt;br&gt;
//000029: &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
//000030: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.WriteLine(i);&lt;br&gt;
&amp;nbsp; IL_0004:&amp;nbsp; ldloc.0&lt;br&gt;
&amp;nbsp; IL_0005:&amp;nbsp; box&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [mscorlib]System.Int32&lt;br&gt;
&amp;nbsp; IL_000a:&amp;nbsp; call&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; void [System]System.Diagnostics.Debug::WriteLine(object)&lt;br&gt;
//000028: &amp;nbsp;&amp;nbsp;&amp;nbsp;for(int i = 0; i&amp;lt;10; i++)&lt;br&gt;
&amp;nbsp; IL_000f:&amp;nbsp; ldloc.0&lt;br&gt;
&amp;nbsp; IL_0010:&amp;nbsp; ldc.i4.1&lt;br&gt;
&amp;nbsp; IL_0011:&amp;nbsp; add&lt;br&gt;
&amp;nbsp; IL_0012:&amp;nbsp; stloc.0&lt;br&gt;
&amp;nbsp; IL_0013:&amp;nbsp; ldloc.0&lt;br&gt;
&amp;nbsp; IL_0014:&amp;nbsp; ldc.i4.s&amp;nbsp;&amp;nbsp; 10&lt;br&gt;
&amp;nbsp; IL_0016:&amp;nbsp; blt.s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IL_0004&lt;br&gt;
//000029: &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
//000030: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Debug.WriteLine(i);&lt;br&gt;
//000031: &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
//000032: &amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp; IL_0018:&amp;nbsp; ret&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
You will notice that there is no reference to the Interlock class nor the Math class,
which is reassuring.&amp;nbsp; It's simply looping through and adding 1 to i.&amp;nbsp; Time
to do a little speed test in VB.NET and see what happens when we use the ugly converted
code versus the vanilla implementation.
&lt;/p&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td colspan="3"&gt;
&lt;b&gt;Time (milliseconds)&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;font face="Arial" size="2"&gt;Iterations&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font face="Arial" size="2"&gt;Vanilla&lt;/font&gt;&lt;/td&gt;
&lt;td&gt;
&lt;font face="Arial" size="2"&gt;Converted&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;10&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;16&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;16&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;100&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;93&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;93&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;1000&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;1050&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;1105&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;10000&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;15900&lt;/font&gt;&lt;/td&gt;
&lt;td align="right"&gt;
&lt;font face="Arial" size="2"&gt;26300&lt;/font&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
Like almost every programming sin, the results are not evident in small samples, but
become glaring when you actually start doing something intensive.&amp;nbsp; In fact running
the 10,000 iterations on the converted code caused my little test app to crash occassionally. 
&lt;/p&gt;
&lt;p&gt;
The moral?&amp;nbsp;If you use a code converter:&lt;br&gt;
a) Find a good one&lt;br&gt;
b) Don't take it as the gospel truth&lt;br&gt;
c) Clean up after it when it makes boo-boos, especially obvious ones. 
&lt;/p&gt;
&lt;p&gt;
Found a couple of goodies while researching this entry.&amp;nbsp; This is an &lt;a href="http://msdn.microsoft.com/msdnmag/issues/06/02/PasteAs/"&gt;article
about a VS add-in &lt;/a&gt;to paste a chunk of C# code as VB code.&amp;nbsp; Looks pretty cool.
&lt;/p&gt;
&lt;p&gt;
And this is a list of&amp;nbsp;&lt;a href="http://research.microsoft.com/research/downloads/"&gt;research
tools&amp;nbsp;&lt;/a&gt;you can download from Microsoft.&amp;nbsp; Note the reference to &lt;a href="http://msdn.microsoft.com/msdnmag/issues/05/07/EndBracket/"&gt;F#!&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=bb634e82-a78f-4fca-9d5d-a63616d70f99" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,bb634e82-a78f-4fca-9d5d-a63616d70f99.aspx</comments>
      <category>.NET</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=f9e23a2f-3509-4a0b-919b-56ce4793ef18</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,f9e23a2f-3509-4a0b-919b-56ce4793ef18.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,f9e23a2f-3509-4a0b-919b-56ce4793ef18.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=f9e23a2f-3509-4a0b-919b-56ce4793ef18</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">First the good news, there is a cool new
method on the string class, instead of having to do the following...<br /><br /><blockquote><font color="#000080" face="Courier New">if(astring != null)</font><br /><font color="#000080" face="Courier New">   if(astring.Length &gt; 0)</font><br /><font color="#000080" face="Courier New">      bstring =
astring;</font><br /></blockquote><br />
There is the new <a href="http://msdn2.microsoft.com/en-us/library/490acw3e.aspx">String.IsNullOrEmpty</a> function
that allows you do this...<br /><br /><blockquote><font color="#000080" face="Courier New">  if(!String.IsNullOrEmpty(astring))</font><br /><font color="#000080" face="Courier New">     bstring = astring;</font><br /></blockquote><br />
OK, it doesn't save a lot of code, but it's a 33% savings and it makes for more readable
code.  Also it is <a href="http://www.gotdotnet.com/team/fxcop/Docs/Rules/Performance/TestForEmptyStringsUsingStringLength.html">faster</a> than
using the string == "" 
<br /><br /><blockquote><font color="#000080" face="Courier New">if(astring != null)</font><br /><font color="#000080" face="Courier New">   if(astring == "")</font><br /><font color="#000080" face="Courier New">      bstring =
astring;</font><br /></blockquote><br />
and it won't throw a null execption that would occur on the following if you don't
check for a null first.<br /><br /><br /><font color="#000080" face="Courier New">   if(astring.length == 0)</font><br /><font color="#000080" face="Courier New">      bstring =
astring;<br /><br /></font>Now, for some disturbing news about <a href="http://blogs.msdn.com/toddca/archive/2005/12/01/499144.aspx">app
recycling when your web app deletes files or directories.</a>  Mike Belcher found
this the hard way, his sessions were dying and he didn't know why.  He was deleting
some files, which worked fine in 1.1, but if you delete too many in 2.0, hello recycling,
good-bye sessions.  Here's some more<a href="http://weblogs.asp.net/owscott/"> info</a>.<br /><br />
This is some major foo.  If you are running some intensive logging or doing lots
of file uploading, you can blow up your app info, sessions and cache without having
a clue why.  The suggested workaround (using junction points) is a little tedious
and  is also not viable for shared hosting systems. 
<br /><br /><b><font color="#ff0000">A better workaround is buried in one of the comments of Scott's
blog</font>...</b><br /><br />
The App_Data folder of the web app is NOT monitored by the File Change Notification,
so if any part of your web app needs to do lots of file or directory manipulation,
do it there to prevent sudden AppDomain recycling.<br /><br />
I'm surprised that this new "feature" didn't bite more people on the ass during the
beta period. 
<br /><br />
 In a perfect world, a patch to turn off this behavior will be available soon.<font color="#000080" face="Courier New"><br /></font><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=f9e23a2f-3509-4a0b-919b-56ce4793ef18" /></body>
      <title>Good News, Bad News</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,f9e23a2f-3509-4a0b-919b-56ce4793ef18.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,f9e23a2f-3509-4a0b-919b-56ce4793ef18.aspx</link>
      <pubDate>Fri, 24 Mar 2006 03:55:17 GMT</pubDate>
      <description>First the good news, there is a cool new method on the string class, instead of having to do the following...&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;if(astring != null)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; if(astring.Length &amp;gt; 0)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bstring =
astring;&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
There is the new &lt;a href="http://msdn2.microsoft.com/en-us/library/490acw3e.aspx"&gt;String.IsNullOrEmpty&lt;/a&gt; function
that allows you do this...&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp; if(!String.IsNullOrEmpty(astring))&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bstring = astring;&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
OK, it doesn't save a lot of code, but it's a 33% savings and it makes for more readable
code.&amp;nbsp; Also it is &lt;a href="http://www.gotdotnet.com/team/fxcop/Docs/Rules/Performance/TestForEmptyStringsUsingStringLength.html"&gt;faster&lt;/a&gt; than
using the string == "" 
&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;&lt;font color="#000080" face="Courier New"&gt;if(astring != null)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; if(astring == "")&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bstring =
astring;&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
and it won't throw a null execption that would occur on the following if you don't
check for a null first.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp; if(astring.length == 0)&lt;/font&gt;
&lt;br&gt;
&lt;font color="#000080" face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bstring =
astring;&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;Now, for some disturbing news about &lt;a href="http://blogs.msdn.com/toddca/archive/2005/12/01/499144.aspx"&gt;app
recycling when your web app deletes files or directories.&lt;/a&gt;&amp;nbsp; Mike Belcher found
this the hard way, his sessions were dying and he didn't know why.&amp;nbsp; He was deleting
some files, which worked fine in 1.1, but if you delete too many in 2.0, hello recycling,
good-bye sessions.&amp;nbsp; Here's some more&lt;a href="http://weblogs.asp.net/owscott/"&gt; info&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
This is some major foo.&amp;nbsp; If you are running some intensive logging or doing lots
of file uploading, you can blow up your app info, sessions and cache without having
a clue why.&amp;nbsp; The suggested workaround (using junction points) is a little tedious
and&amp;nbsp; is also not viable for shared hosting systems. 
&lt;br&gt;
&lt;br&gt;
&lt;b&gt;&lt;font color="#ff0000"&gt;A better workaround is buried in one of the comments of Scott's
blog&lt;/font&gt;...&lt;/b&gt;
&lt;br&gt;
&lt;br&gt;
The App_Data folder of the web app is NOT monitored by the File Change Notification,
so if any part of your web app needs to do lots of file or directory manipulation,
do it there to prevent sudden AppDomain recycling.&lt;br&gt;
&lt;br&gt;
I'm surprised that this new "feature" didn't bite more people on the ass during the
beta period. 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;In a perfect world, a patch to turn off this behavior will be available soon.&lt;font color="#000080" face="Courier New"&gt;
&lt;br&gt;
&lt;/font&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=f9e23a2f-3509-4a0b-919b-56ce4793ef18" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,f9e23a2f-3509-4a0b-919b-56ce4793ef18.aspx</comments>
      <category>.NET</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=4f1a8021-37cb-4e3c-8d64-4147e1656d7e</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,4f1a8021-37cb-4e3c-8d64-4147e1656d7e.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,4f1a8021-37cb-4e3c-8d64-4147e1656d7e.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=4f1a8021-37cb-4e3c-8d64-4147e1656d7e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Among the many improvements of .NET 2.0 is a subtle but welcome one in GridView, the
replacement to the DataGrid control. 
</p>
        <p>
The Items have finally left the building.  Any old kinda grid control should
have columns and rows.
</p>
        <p>
The DataGrid had Columns and <em>Items</em>?
</p>
        <p>
What in the world is an <em>Item</em>?  It's a row, but it's not called that
-- for a very good reason I am sure.
</p>
        <p>
The GridView has Columns and <strong>Rows</strong>!
</p>
        <p>
Hooray! 
</p>
        <p>
Instead of ItemCreated, or ItemDataBound event handlers, there are RowCreated and
RowDataBound.  Instead of ItemType there is RowType.
</p>
        <p>
I cannot tell you how confusing this was for developers when first working with the
DataGrid.  "How can I access a row?" must have been screamed at monitors
from Mountain View to Mumbay.
</p>
        <p>
What things are named can greatly affect how easy/hard it is use someone else's interface
or maintain code.  How many times have you written code for something, only to
find the same functionality in an obscurely/badly named function or class?
</p>
        <p>
Consistent, meaningful naming makes it much easier for someone else, or the future
you (go read some code you haven't touched in a year) to get what you are trying to
do.
</p>
        <p>
I must confess that I have not always been the best practioner.  My original
programming platform was the Apple II, and variable names were limited to 8 characters
(only the first three of which were meaningful -- found that out the HARD way), and
I've never fully overcome the combined effects of that and my Modified Hunt &amp;
Peck Typing skills. 
</p>
        <p>
This is something I have worked to be better at, but this <a href="http://aspadvice.com/lists/message.aspx?MessageID=167068">post</a> from
Ryan Olshan really made it hit home.  I will paraphrase his thesis as "Variable
names should be like characters in novel, they should be easily identifiable and make the
reader care what happens to them".  
</p>
        <p>
Especially with Intellisense and the built-in refactoring tools in Visual Studio (this <a href="http://msdn2.microsoft.com/en-us/library/ckfya594(VS.80).aspx">one </a>especially),
there is no reason to skimp on meaningful naming and it's easy to fix past mistakes.
</p>
        <img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=4f1a8021-37cb-4e3c-8d64-4147e1656d7e" />
      </body>
      <title>There Is Something In a Name</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,4f1a8021-37cb-4e3c-8d64-4147e1656d7e.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,4f1a8021-37cb-4e3c-8d64-4147e1656d7e.aspx</link>
      <pubDate>Wed, 15 Mar 2006 17:41:54 GMT</pubDate>
      <description>&lt;p&gt;
Among the many improvements of .NET 2.0 is a subtle but welcome one in GridView, the
replacement to the DataGrid control. 
&lt;/p&gt;
&lt;p&gt;
The Items have finally left the building.&amp;nbsp; Any old kinda grid control should
have columns and rows.
&lt;/p&gt;
&lt;p&gt;
The DataGrid had Columns and &lt;em&gt;Items&lt;/em&gt;?
&lt;/p&gt;
&lt;p&gt;
What in the world is an &lt;em&gt;Item&lt;/em&gt;?&amp;nbsp; It's a row, but it's not called that
-- for a very good reason I am sure.
&lt;/p&gt;
&lt;p&gt;
The GridView has Columns and &lt;strong&gt;Rows&lt;/strong&gt;!
&lt;/p&gt;
&lt;p&gt;
Hooray! 
&lt;/p&gt;
&lt;p&gt;
Instead of ItemCreated, or ItemDataBound event handlers, there are RowCreated and
RowDataBound.&amp;nbsp; Instead of ItemType there is RowType.
&lt;/p&gt;
&lt;p&gt;
I cannot tell you how confusing this was for developers when first working with the
DataGrid.&amp;nbsp; "How can I access a row?"&amp;nbsp;must have been screamed&amp;nbsp;at monitors
from Mountain View to Mumbay.
&lt;/p&gt;
&lt;p&gt;
What things are named can greatly affect how easy/hard it is use someone else's interface
or maintain code.&amp;nbsp; How many times have you written code for something, only to
find the same functionality in an obscurely/badly named function or class?
&lt;/p&gt;
&lt;p&gt;
Consistent, meaningful naming makes it much easier for someone else, or the future
you (go read some code you haven't touched in a year) to get what you are trying to
do.
&lt;/p&gt;
&lt;p&gt;
I must confess that I have not always been the best practioner.&amp;nbsp; My original
programming platform was the Apple II, and variable names were limited to 8 characters
(only the first three of which were meaningful -- found that out the HARD way), and
I've never fully overcome the combined effects of that and my Modified Hunt &amp;amp;
Peck Typing skills.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
This is something I have&amp;nbsp;worked to be better at, but&amp;nbsp;this &lt;a href="http://aspadvice.com/lists/message.aspx?MessageID=167068"&gt;post&lt;/a&gt; from
Ryan Olshan really made it hit home.&amp;nbsp; I will paraphrase his thesis as "Variable
names should be like characters in novel, they should be easily identifiable and make&amp;nbsp;the
reader&amp;nbsp;care what happens to them".&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Especially with Intellisense and the built-in refactoring tools in Visual Studio (this &lt;a href="http://msdn2.microsoft.com/en-us/library/ckfya594(VS.80).aspx"&gt;one &lt;/a&gt;especially),
there is no reason to skimp on meaningful naming and it's easy to fix past mistakes.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=4f1a8021-37cb-4e3c-8d64-4147e1656d7e" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,4f1a8021-37cb-4e3c-8d64-4147e1656d7e.aspx</comments>
      <category>.NET</category>
      <category>Good Practices</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4</wfw:commentRss>
      <slash:comments>7</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">One of those stupid things...<br /><br />
I opened up a 2.0 website I was working on and Visual Studio decided it needed to
be converted. Not sure why, unfortunately I wasn't paying attention.  Fortunately,
I did tell VS to back up the project.  Went to run the website, which was working
yesterday.  I get an allowDefinition='MachineToApplication' error.  What
the <a href="http://en.wikipedia.org/wiki/Fuck">badword</a> !?!<br /><br />
(BTW, I believe coding -- much like plumbing -- requires lots of swearing to let off
steam to save passers-by and inanimate objects from more physical acts of aggression.)<br /><br />
My first, VERY ERRONEOUS, thought was that the stupid project was trying to run under
IIS, which I didn't want it to do.  I had been running it under the very handy <a href="http://msdn2.microsoft.com/en-us/library/58wxa9w5.aspx">ASP.NET
Development Web Server</a>. But I thought, I'll play along.  I created a virtual
directory under my local IIS and pointed it to my website.<br /><br />
Same friggin' error.  More swearing.  Some googling.  What's going
on?<br /><br />
Finally, looking at the directory structure, I see the backup folder and decide to
just open the old project.  I nuke the "converted" website and copy the old files
into the directroy stucture, "wisely" leaving the backup folder intact, just in case.<br /><br />
Same friggin' error.  More swearing.  
<br /><br />
Then it hits me.  The backup folder has a web.config file in it. I move the backup
folder out of my website tree.  I run the website.<br /><br />
It works. I get the last of the swearing out of my system.<br /><br />
The moral of the story, if you are getting the allowDefinition='MachineToApplication'
error, and you have done everything to ensure you have a virtual directory set up
with an application, check the rest of the tree to make sure you don't have a friggin'
backup web.config file screwing things up.  
<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4" /></body>
      <title>allowDefinition='MachineToApplication'</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4.aspx</link>
      <pubDate>Tue, 07 Mar 2006 20:50:17 GMT</pubDate>
      <description>One of those stupid things...&lt;br&gt;
&lt;br&gt;
I opened up a 2.0 website I was working on and Visual Studio decided it needed to
be converted. Not sure why, unfortunately I wasn't paying attention.&amp;nbsp; Fortunately,
I did tell VS to back up the project.&amp;nbsp; Went to run the website, which was working
yesterday.&amp;nbsp; I get an allowDefinition='MachineToApplication' error.&amp;nbsp; What
the &lt;a href="http://en.wikipedia.org/wiki/Fuck"&gt;badword&lt;/a&gt; !?!&lt;br&gt;
&lt;br&gt;
(BTW, I believe coding -- much like plumbing -- requires lots of swearing to let off
steam to save passers-by and inanimate objects from more physical acts of aggression.)&lt;br&gt;
&lt;br&gt;
My first, VERY ERRONEOUS, thought was that the stupid project was trying to run under
IIS, which I didn't want it to do.&amp;nbsp; I had been running it under the very handy &lt;a href="http://msdn2.microsoft.com/en-us/library/58wxa9w5.aspx"&gt;ASP.NET
Development Web Server&lt;/a&gt;. But I thought, I'll play along.&amp;nbsp; I created a virtual
directory under my local IIS and pointed it to my website.&lt;br&gt;
&lt;br&gt;
Same friggin' error.&amp;nbsp; More swearing.&amp;nbsp; Some googling.&amp;nbsp; What's going
on?&lt;br&gt;
&lt;br&gt;
Finally, looking at the directory structure, I see the backup folder and decide to
just open the old project.&amp;nbsp; I nuke the "converted" website and copy the old files
into the directroy stucture, "wisely" leaving the backup folder intact, just in case.&lt;br&gt;
&lt;br&gt;
Same friggin' error.&amp;nbsp; More swearing.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
Then it hits me.&amp;nbsp; The backup folder has a web.config file in it. I move the backup
folder out of my website tree.&amp;nbsp; I run the website.&lt;br&gt;
&lt;br&gt;
It works. I get the last of the swearing out of my system.&lt;br&gt;
&lt;br&gt;
The moral of the story, if you are getting the allowDefinition='MachineToApplication'
error, and you have done everything to ensure you have a virtual directory set up
with an application, check the rest of the tree to make sure you don't have a friggin'
backup web.config file screwing things up.&amp;nbsp; 
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,c39d11ac-33a7-4d5c-bf55-41ea4d25c7e4.aspx</comments>
      <category>.NET</category>
      <category>web.config</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1</wfw:commentRss>
      <title>XslTransform Deprecated</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx</link>
      <pubDate>Mon, 06 Mar 2006 21:01:38 GMT</pubDate>
      <description>I have a number of code libraries I have created or inherited.&amp;nbsp; As time allows or urgency requires I am busily converting them into .NET 2.0 projects.&amp;nbsp; For the most part this is straightforward, but every now and again I run into something interesting that requires a little more digging/coding/swearing.&lt;br&gt;
&lt;br&gt;
Today I discovered the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.xml.xsl.xsltransform.aspx"&gt;XslTransform&lt;/a&gt; class
has been deprecated in 2.0.&amp;nbsp; Since I do a fair amount of work with XSLT I decided
I should pay attention to the little compilier warning Visual Studio was kind enough
to generate and see what I should be using instead.&amp;nbsp; The new preferred class
is &lt;a href="http://msdn2.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx"&gt;XslCompiledTransform&lt;/a&gt; and
Microsoft has also generated handy guides for &lt;a href="http://msdn2.microsoft.com/en-us/library/0610k0w4.aspx"&gt;using
the new beast &lt;/a&gt;and to &lt;a href="http://msdn2.microsoft.com/en-us/library/66f54faw.aspx"&gt;migrating
your old XslTransform code&lt;/a&gt;.&amp;nbsp; Clearly there was a fairly meaty change made,
so time to do some reading.&lt;br&gt;
&lt;br&gt;
The documentation promises increased performance and also states "The new XSLT processor
compiles the XSLT style sheet down to a common intermediate format, similar to what
the common language runtime (CLR) does for other programming languages. Once the style
sheet is compiled, it can be cached and reused."&amp;nbsp; Very interesting.&amp;nbsp; I will
have to do some side-to-side comparison tests for performance at some point, but what
do I have to do now to get my old code using XslCompiledTransform?&lt;br&gt;
&lt;br&gt;
The function I need to change takes an XML document, calls another function that returns
custom XSLT and then uses this to transform the input document and write it to a&amp;nbsp;
string representation of an XML document.&amp;nbsp; The transformation simply sorts the
document based on a number of supplied parameters.&amp;nbsp; (There is a better way to
do this, but I inherited this particular method and it "works".&amp;nbsp; Also the need
for the method will be removed shortly, so I just want to get it work in 2.0.)&lt;br&gt;
&lt;br&gt;
Replacing the XslTransform class with XslCompiledTransfrom causes an error in the
.Transform call that is the heart of the procedure...&lt;br&gt;
&lt;blockquote&gt;&lt;font face="Courier New"&gt;Dim xTrans as XslCompiledTransform&lt;br&gt;
'1.1 overload (IXPathNavigable, XsltArgument,TextWriter, XmlResolver) - &lt;a href="http://msdn2.microsoft.com/en-us/library/ms163488.aspx"&gt;Documentation&lt;/a&gt;
&lt;br&gt;
xTrans.Transform(&lt;/font&gt;&lt;font face="Courier New" color=#ff0000&gt;&lt;u&gt;InputXMLDoc&lt;/u&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;,
Nothing, &lt;/font&gt;&lt;font face="Courier New" color=#ff0000&gt;&lt;u&gt;XMLStringWriter&lt;/u&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;,
Nothing)&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;Looking at the overloads for XslCompiledTransform.Transform reveals that
what I want to do is...&lt;br&gt;
&lt;font face="Courier New"&gt;
&lt;br&gt;
&lt;/font&gt; &lt;blockquote&gt;&lt;font face="Courier New"&gt;'2.0 overload (IXPathNavigable, XsltArgument,TextWriter)&lt;/font&gt;
&lt;br&gt;
&lt;font face="Courier New"&gt;xTrans.Transform(InputXMLDoc&lt;/font&gt;&lt;font face="Courier New"&gt;,
Nothing, &lt;/font&gt;&lt;font face="Courier New" color=#006400&gt;XMLStringWriter&lt;/font&gt;&lt;font face="Courier New"&gt;)&lt;/font&gt;
&lt;br&gt;
&lt;/blockquote&gt;&lt;font face="Courier New"&gt;
&lt;br&gt;
The code wasn't using the &lt;/font&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/system.xml.xmlresolver.aspx&gt;Resolver&lt;/A&gt; anyway, which is only used if you need to reference external resources such other DTDs or stylesheet namespaces, which isn't the case here.&amp;nbsp; If I wanted to use a resolver, I would need to use the one &lt;A href="http://msdn2.microsoft.com/en-us/library/ms163443.aspx"&gt;Transform
overloads&lt;/a&gt; (of 14) that supports it, which requires an XMLReader as an input and
an XMLWriter as an output. Fortunately, I don't need to do that much rewriting.&amp;nbsp;
Dropping the unused XmlResolver parm does just what I need.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,5b40fbc8-2743-48a9-b9e8-d9e394ad4ba1.aspx</comments>
      <category>.NET</category>
      <category>XSLT</category>
    </item>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=471a79a6-34ee-42ab-84c0-6d4097cf44b9</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,471a79a6-34ee-42ab-84c0-6d4097cf44b9.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,471a79a6-34ee-42ab-84c0-6d4097cf44b9.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=471a79a6-34ee-42ab-84c0-6d4097cf44b9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">I've been seeing everything as base classes
lately. Not sure it is a good thing or a sign of insanity.<br /><br />
Had to do some driving of Excel from a web app -- not really something one should
do as a matter of course -- but sometimes business requirements force more insanity
than usual.<br /><br />
But I decided as long as I was going go insane, I was only going to do it once, so
I created a base class that wrapped up all the goodies to open and close a workbook,
get cell values, set cell values, etc. Excel exposes everything via COM.  .NET
sets up the InterOp automatically, but if you've worked with automating Office apps,
you know they are finicky about closing cleanly, so the destructor handles closing
the workbook and quiting the app.  Works very nicely.<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=471a79a6-34ee-42ab-84c0-6d4097cf44b9" /></body>
      <title>Objects, Objects Everywhere</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,471a79a6-34ee-42ab-84c0-6d4097cf44b9.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,471a79a6-34ee-42ab-84c0-6d4097cf44b9.aspx</link>
      <pubDate>Thu, 02 Mar 2006 03:45:02 GMT</pubDate>
      <description>I've been seeing everything as base classes lately. Not sure it is a good thing or a sign of insanity.&lt;br&gt;
&lt;br&gt;
Had to do some driving of Excel from a web app -- not really something one should
do as a matter of course -- but sometimes business requirements force more insanity
than usual.&lt;br&gt;
&lt;br&gt;
But I decided as long as I was going go insane, I was only going to do it once, so
I created a base class that wrapped up all the goodies to open and close a workbook,
get cell values, set cell values, etc. Excel exposes everything via COM.&amp;nbsp; .NET
sets up the InterOp automatically, but if you've worked with automating Office apps,
you know they are finicky about closing cleanly, so the destructor handles closing
the workbook and quiting the app.&amp;nbsp; Works very nicely.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=471a79a6-34ee-42ab-84c0-6d4097cf44b9" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,471a79a6-34ee-42ab-84c0-6d4097cf44b9.aspx</comments>
      <category>.NET</category>
      <category>Excel</category>
      <category>InterOp</category>
    </item>
  </channel>
</rss>