<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Charlie Calvert's Community Blog</title><subtitle type="html" /><id>http://blogs.msdn.com/charlie/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/charlie/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2009-09-21T14:05:20Z</updated><entry><title>HDI Video: Generate from Usage in Visual Studio 2010 with Karen Liu</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/11/07/hdi-video-generate-from-usage-with-karen-liu.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/11/07/hdi-video-generate-from-usage-with-karen-liu.aspx</id><published>2009-11-07T23:45:00Z</published><updated>2009-11-07T23:45:00Z</updated><content type="html">&lt;style type="text/css"&gt;




span.squiggle { color: red; text-decoration: underline;}
.listing { font-weight: bold }
.figure { font-weight: bold }
.note { font-weight: italic; background: lightgray; border: 1px solid black; }&lt;/style&gt;  &lt;p&gt;Karen Liu, the Lead Program Manager for the Visual C# and Visual Basic IDEs, has created a &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee633445.aspx"&gt;new video&lt;/a&gt; on &lt;a href="http://msdn.microsoft.com/en-us/library/dd409796(VS.100).aspx"&gt;Generate from Usage&lt;/a&gt; (GFU), a feature found in Visual Studio 2010, Beta 2. This post recaps what is included in the video, including the sections that show how GFU can be used to enhance &lt;a href="http://www.extremeprogramming.org/rules/testfirst.html"&gt;test first development&lt;/a&gt;. The video is shot in both VB and C#. Since this is a C# blog, I’ll show only C# code, and will translate the VB code that Karen shows into C#.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=8077"&gt;source code&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ Farm&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Generate from Usage (GFU) is a new feature in 2010 that allows you to write code that consumes a library or API before that API even exists. Using Visual Studio menus or shortcuts, you can automatically generate classes, constructors, methods, fields and properties from the code you typed in the editor.&lt;/p&gt;  &lt;p&gt;As the video begins, Karen first types in the code to initialize a class called &lt;strong&gt;Automobile&lt;/strong&gt; that does not yet exist:&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cf3a3f0-6bee-4a46-8d17-8a5e29158786" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; myCar = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; Automobile(Make: &lt;span style="color:#a31515"&gt;&amp;quot;Honda&amp;quot;&lt;/span&gt;, Model: &lt;span style="color:#a31515"&gt;&amp;quot;Accord&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Notice that the class name &lt;strong&gt;Automobile&lt;/strong&gt; is &lt;u&gt;not&lt;/u&gt; colored in teal, which is Visual Studio’s way of telling you that it does not yet it exist. When seen inside Visual Studio, the word &lt;strong&gt;Automobile&lt;/strong&gt; will also have red squiggly (or wavy) underline, and a small blue&lt;strong&gt; smart tag &lt;/strong&gt;under the letter A, as shown in Figure 1. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure01_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure01_thumb.png" width="644" height="161" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 1: The red squiggle is Visual Studio’s way of telling you that the type &lt;u&gt;Automobile&lt;/u&gt; will not compile. The blue &lt;em&gt;smart tag&lt;/em&gt; under the letter A let’s the user know that an expansion tip is available by simultaneously pressing the Control key and a period (Ctrl + .).&lt;/p&gt;  &lt;p&gt;The smart tag under the letter A is Visual Studio’s way of telling you to press the control and period keys to bring up a special expansion tip, as shown in Figure 2. Here we see two options, one for directly creating a class called &lt;strong&gt;Automobile&lt;/strong&gt;, and the other for bringing up a dialog which allows us to define or tweak the details of the type of we create.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure02_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure02_thumb.png" width="644" height="247" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 2: Viewing an expansion tip in Visual Studio.&lt;/p&gt;  &lt;p&gt;You can also bring up the options to create a new class or type by right clicking on the word &lt;strong&gt;Automobile&lt;/strong&gt; and selecting &lt;strong&gt;Generate&lt;/strong&gt; from the popup menu, as shown in Figure 3.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure03_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure03" border="0" alt="Figure03" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure03_thumb.png" width="644" height="174" /&gt;&lt;/a&gt; &lt;/strong&gt;&lt;/p&gt;  &lt;p class="figure"&gt;Figure 3: A second way to generate a class is to right click the word &lt;u&gt;Automobile&lt;/u&gt; and choose &lt;u&gt;Generate &lt;/u&gt;from the popup menu.&lt;/p&gt;  &lt;p&gt;If you select the option to create a new class, then Visual Studio will automatically generate a new file called &lt;strong&gt;Automobile.cs&lt;/strong&gt; and place inside it a new class called &lt;strong&gt;Automobile&lt;/strong&gt;. The entire generated file is shown in Listing 1.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 1: The code generate when you choose to create a new class based on an undefined identifier in Visual Studio 2010.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51302077-3aa5-4dcb-94f7-45db8bcc830f" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; DeleteMe&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;You can now go back to your original source file where you will see that there is still a red squiggly and blue tool tip, as shown in Figure 4. These hints are shown because we have not yet created a constructor for the &lt;strong&gt;Automobile&lt;/strong&gt; class. If we again press control plus period, then the option to generate these code elements is made available to us, as shown in Figure 4.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure04_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure04" border="0" alt="Figure04" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure04_thumb_1.png" width="644" height="146" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 4: Selecting the smart tag a second time brings up an option to automatically generate the constructor and associated fields for your class.&lt;/p&gt;  &lt;p&gt;The code that is generated by selecting the expansion tip is shown in Listing 2. Notice that on lines 10 and 11 fields were created for your class and on lines 16 and 17 code was generated inside the constructor for initializing them. A comment in the form of a &lt;strong&gt;TODO&lt;/strong&gt; item is also added to your class. These &lt;strong&gt;TODO&lt;/strong&gt; items are visible in the Visual Studio &lt;a href="http://msdn.microsoft.com/en-us/library/zce12xx2(VS.100).aspx"&gt;Task List&lt;/a&gt;. You can access the &lt;strong&gt;Task List &lt;/strong&gt;by choosing &lt;strong&gt;View | Task List &lt;/strong&gt;from the menu, or by pressing &lt;strong&gt;Ctrl+W, T&lt;/strong&gt;. Be sure to choose the &lt;strong&gt;Comments&lt;/strong&gt; option from the drop down at the top of the &lt;strong&gt;Task List&lt;/strong&gt;.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 2: The code for the Automobile’s constructor is automatically generated by the IDE.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:39825868-2600-44c3-aca2-c3e2393bc188" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; GenerateFromUsageSample&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Automobile(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#008000"&gt;// TODO: Complete member initialization&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Make = Make;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Model = Model;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Karen next types in code for a &lt;strong&gt;TurnLeft &lt;/strong&gt;method, and for a property called &lt;strong&gt;IsFacingNorth&lt;/strong&gt;. As she types each item, a smart tag appears, and again she has the option to press &lt;strong&gt;Ctrl+.&lt;/strong&gt; to automatically generate code for the &lt;strong&gt;Automobile &lt;/strong&gt;class. The code typed in the program’s entry point is shown in Listing 3, and the code generated by the IDE is shown mostly in Listing 4. Notice, however, that code for a private object called &lt;strong&gt;distance &lt;/strong&gt;was automatically generated in the &lt;strong&gt;Main&lt;/strong&gt; method. The IDE actually gives you the option to create either a &lt;strong&gt;private &lt;/strong&gt;field, as shown here, or a &lt;strong&gt;public&lt;/strong&gt; property.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 3: The complete code for Karen’s first sample includes a constructor, a method called &lt;u&gt;TurnLeft&lt;/u&gt;, and a property called &lt;u&gt;IsFacingNorth&lt;/u&gt;.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:98dfe693-a81d-4df2-8435-00a22ea59678" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; GenerateFromUsage&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Program&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; distance;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] args)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; myCar = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;(Make: &lt;span style="color:#a31515"&gt;&amp;quot;Honda&amp;quot;&lt;/span&gt;, Model: &lt;span style="color:#a31515"&gt;&amp;quot;Accord&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;myCar.TurnLeft(distance);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;myCar.IsFacingNorth = &lt;span style="color:#0000ff"&gt;true&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p class="listing"&gt;Listing 4: The code generated by the IDE for the TurnLeft method and the IsFacingNorth property.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f7d9d6bd-a681-4139-b84f-0468606a8287" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; GenerateFromUsage&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Automobile&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; Automobile(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Make, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Model)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#008000"&gt;// TODO: Complete member initialization&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Make = Make;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;.Model = Model;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;internal&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; TurnLeft(&lt;span style="color:#0000ff"&gt;object&lt;/span&gt; distance)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;NotImplementedException&lt;/span&gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;bool&lt;/span&gt; IsFacingNorth { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;; }&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;When looking at Listing 4, notice that code for generating a &lt;strong&gt;NotImplementedException &lt;/strong&gt;is automatically generated in the &lt;strong&gt;TurnLeft &lt;/strong&gt;method. The IDE was also smart enough to discern that the &lt;strong&gt;IsFacingNorth&lt;/strong&gt; property returns a &lt;strong&gt;bool&lt;/strong&gt;. All the lines of code shown in Listing 4 were generated by typing just three lines of code in the &lt;strong&gt;main &lt;/strong&gt;method found in Listing 3.&lt;/p&gt;  &lt;h2&gt;The C# Side&lt;/h2&gt;  &lt;p&gt;In the second part of the video Karen shows how you can use &lt;em&gt;generate from usage&lt;/em&gt; (GFU) to enhance your experience when creating unit tests. Many theorists advocate using a test first methodology in which you first create a test, and then write the code that you want to test. You will see that GFU can be used to make this style of development quite natural and simple to use inside of Visual Studio.&lt;/p&gt;  &lt;p class="note"&gt;NOTE: This section of the post requires high end versions of Visual Studio that contain the test wizards. Even if you don’t have those tools, you can still follow along to see how Generate from Usage can be used in all versions of Visual Studio to make it easier to create unit tests.&lt;/p&gt;  &lt;p&gt;Begin by starting a new console application called &lt;strong&gt;Customer&lt;/strong&gt;. Choose &lt;strong&gt;Tests | New Test &lt;/strong&gt;from the Visual Studio menu. Select &lt;strong&gt;Basic Unit Test&lt;/strong&gt; from the dialog, and name it &lt;strong&gt;Customers&lt;/strong&gt;, as shown in Figure 5. When you press &lt;strong&gt;OK &lt;/strong&gt;in the &lt;strong&gt;Add New Test &lt;/strong&gt;dialog you will be prompted for the name of your unit test project. Type in &lt;strong&gt;CustomerTests&lt;/strong&gt;. When you are done, the &lt;strong&gt;Solution Explorer&lt;/strong&gt; for your project should look as it does in Figure 6.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure06_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure06" border="0" alt="Figure06" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure06_thumb.png" width="577" height="484" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 5: Create a new unit test project that will house a file called Customers.&lt;/p&gt;  &lt;p&gt;Right click on the &lt;strong&gt;Customer&lt;/strong&gt; node in the &lt;strong&gt;solution explorer&lt;/strong&gt; and choose &lt;strong&gt;Add | New Folder&lt;/strong&gt; to create a new directory called &lt;strong&gt;Models&lt;/strong&gt;. When you are done you should see a new node in the &lt;strong&gt;solution explorer&lt;/strong&gt;, as shown in Figure 6. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure07_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure07" border="0" alt="Figure07" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure07_thumb.png" width="315" height="386" /&gt;&lt;/a&gt;&amp;#160; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 6: This solution contains two projects, one a simple console application called &lt;u&gt;Customer &lt;/u&gt;that contains a folder called &lt;u&gt;Models&lt;/u&gt;. The other project is called &lt;u&gt;CustomerTests&lt;/u&gt; and it is designed to hold unit tests.&lt;/p&gt;  &lt;p&gt;I want to check if my Customer list is create correctly. In the Customers file from your test project, create a method called IsCustomerListValid. Inside the method create code to initialize a &lt;strong&gt;CustomerList&lt;/strong&gt; object, as shown in Listing X. &lt;/p&gt;  &lt;p&gt;Listing 5: A simple unit test with the code to initialize a class called CustomerList. Note that the CustomerList is not colored in Teal, since its declaration has not been created yet.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fbbd71a3-4443-4c5b-bdba-8d3dee069dfa" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Text;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Linq;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Microsoft.VisualStudio.TestTools.UnitTesting;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CustomerTests&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Customers&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestMethod&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; IsCustomerListValid()&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;CustomerList cust = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; CustomerList();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;At this stage, there is no CustomerList, so in Visual Studio you will again see the red squiggles and the blue smart tag, just as I showed in Figure 2. Without needing to take your hands off the keyboard, you can press control plus dot to bring up the expansion tips as in Figure 2. This time select &lt;strong&gt;New Type. &lt;/strong&gt;A dialog comes up like the one shown in Figure 7. In the dialog we can change the accessibility, the kind of code to generate and the project file and directory where we want to place it. Set the &lt;strong&gt;Access&lt;/strong&gt; to &lt;strong&gt;public&lt;/strong&gt; and the &lt;strong&gt;Kind&lt;/strong&gt; to &lt;strong&gt;class&lt;/strong&gt;. Use the &lt;strong&gt;Project&lt;/strong&gt; drop down to select the &lt;strong&gt;Customer&lt;/strong&gt; project and the the &lt;strong&gt;Create new file&lt;/strong&gt; drop down to select the &lt;strong&gt;Model&lt;/strong&gt; directory. Type in &lt;strong&gt;CustomerList.cs &lt;/strong&gt;as the name of the file to create. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure05_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure05" border="0" alt="Figure05" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HDIVideoGeneratefromUsagewithKarenLiu_7209/Figure05_thumb.png" width="378" height="407" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p class="figure"&gt;Figure 7. Selecting the kind of type that you want to create, as well as the project, folder and file in which you want to place it.&lt;/p&gt;  &lt;p&gt;When you press OK in the&lt;strong&gt; Generate New Type&lt;/strong&gt; dialog, the new type will be created, and the IDE will add the using directive and the correct references. You can now fill out your test and your generated class as shown in Listing 6 and 7. Note that we have used generate from usage to enhance the &lt;strong&gt;CustomerList&lt;/strong&gt; class with a method called &lt;strong&gt;Add.&lt;/strong&gt; I then manually wrote code to create a list into which the text we pass can be inserted.&lt;/p&gt;  &lt;p class="listing"&gt;Listing 6: A simple unit test.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2d4608a7-da3a-480f-8b2f-520f6b9aea55" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Customer.Models;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Microsoft.VisualStudio.TestTools.UnitTesting;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CustomerTests&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestClass&lt;/span&gt;]&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;Customers&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;[&lt;span style="color:#2b91af"&gt;TestMethod&lt;/span&gt;]&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; IsCustomerListValid()&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;CustomerList&lt;/span&gt; cust = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CustomerList&lt;/span&gt;();&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;cust.Add(&lt;span style="color:#a31515"&gt;&amp;quot;Karen&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(cust);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p class="listing"&gt;Listing 7: The using directive, namespace, CustomerList class and header for the Add method were auto-generated. I manually created the list and inserted the call to Add an item into it.&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c11c353-a69d-4687-bb78-e50d45f80650" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; Customer.Models&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CustomerList&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt; list = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Add(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; p)&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;list.Add(p);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;You can now use the Test | View menu to bring up the Test List Editor and Test View to select and run your test.&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;In this post you got a second look at the code used in Karen Liu’s generate from usage video. You saw that GFU can be used to create classes, constructors, parameters, properties and fields. You also explored the powerful &lt;strong&gt;Generate New Type&lt;/strong&gt; dialog which gives you the flexibility to choose the kind of type you want to create, as well as the project, directory and file in which you want to insert it. Finally, you saw that generate from usage can be powerful aid when you are engaged in test first development.&lt;/p&gt;  &lt;h2&gt;Resources&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=8077"&gt;source code&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ Farm&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee633445.aspx"&gt;The How Do I Generate from Usage Video&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd409796(VS.100).aspx"&gt;Generate from Usage in the MSDN Library&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/vbteam/archive/2008/12/13/walkthrough-tdd-support-with-the-generate-from-usage-feature-in-vs-2010-lisa-feigenbaum.aspx"&gt;Walkthrough: TDD Support with the Generate From Usage Feature in VS 2010 (Lisa Feigenbaum)&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blog.noop.se/archive/2009/06/16/generate-from-usage-in-visual-studio-2010.aspx"&gt;Magnus Martensson on Generate from Usage&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/zce12xx2(VS.100).aspx"&gt;Task Lists and TODO comments in the MSDN Library&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f07%2fhdi-video-generate-from-usage-with-karen-liu.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f07%2fhdi-video-generate-from-usage-with-karen-liu.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9898211" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Visual Studio" scheme="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx" /><category term="Video" scheme="http://blogs.msdn.com/charlie/archive/tags/Video/default.aspx" /><category term="LinqFarm" scheme="http://blogs.msdn.com/charlie/archive/tags/LinqFarm/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /><category term="Testing" scheme="http://blogs.msdn.com/charlie/archive/tags/Testing/default.aspx" /></entry><entry><title>Classic, Lightweight and ScriptFree MSDN Library Views</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/11/06/new-msdn-library-views.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/11/06/new-msdn-library-views.aspx</id><published>2009-11-07T00:58:56Z</published><updated>2009-11-07T00:58:56Z</updated><content type="html">&lt;p&gt;There have been a number of changes to the &lt;a href="http://msdn.microsoft.com/en-us/library/kx37x362.aspx"&gt;MSDN library&lt;/a&gt; of late, and to the way it is integrated with Visual Studio 2010. &lt;a href="http://blogs.msdn.com/kathleen/default.aspx"&gt;Kathleen McGrath&lt;/a&gt; and Mark D'Urso have created a &lt;a href="http://channel9.msdn.com/posts/kmcgrath/New-MSDN-Library-views/"&gt;nice little video&lt;/a&gt; that walks you through some of the new features such as the classic, lightweight and script-free views, as well as the new feedback mechanism. If you have questions about how the new features in the library work you might find that this is a useful way to spend 9 minutes and 36 seconds. &lt;/p&gt;  &lt;p&gt;You might also enjoy &lt;a href="http://channel9.msdn.com/posts/kmcgrath/Help-30-New-Help-System-in-Visual-Studio-2010/"&gt;Kathleen’s video interview&lt;/a&gt; with Ryan Linton. It&amp;#160; focuses on using help from inside Visual Studio.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f06%2fnew-msdn-library-views.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f06%2fnew-msdn-library-views.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9918925" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="Visual Studio" scheme="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx" /><category term="Help System" scheme="http://blogs.msdn.com/charlie/archive/tags/Help+System/default.aspx" /></entry><entry><title>New Article by Bill Wagner on Dynamic Method Bags in C# 4.0</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/11/03/new-article-by-bill-wagner-on-dynamic-method-bags.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/11/03/new-article-by-bill-wagner-on-dynamic-method-bags.aspx</id><published>2009-11-03T22:30:32Z</published><updated>2009-11-03T22:30:32Z</updated><content type="html">&lt;p&gt;C# MVP and wunderkind Bill Wagner has written an article entitled &lt;a href="http://msdn.microsoft.com/en-us/library/ee658247.aspx"&gt;Dynamic Method Bags&lt;/a&gt; which is now available on MSDN. Bill explores the new dynamic feature in C# 4.0. Most posts on this subject explain how to use dynamic to call Python, Ruby or Office. In his article, Bill explains how dynamic can be used not to call another language or tool, but to call your own C# objects without directly using the reflection API’s. The solution he provides combines generics, expression tress and dynamic to create a “type that allows developers to add new methods at runtime” and call those methods through dynamic dispatch.&lt;/p&gt;  &lt;h2&gt;Resources&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee658247.aspx"&gt;Bill’s Dynamic Method Bags article&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://srtsolutions.com/blogs/billwagner/"&gt;Bills Blog&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Download a Doc file providing an &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=csharpfuture&amp;amp;DownloadId=3550"&gt;Overview of C# 4.0 Language Features&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/csharpfuture"&gt;C# Future Samples&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/dd819407.aspx"&gt;Visual C# 2010 Resources&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx"&gt;VS 2010 Walkthroughs&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/vbteam/archive/2008/12/17/walkthrough-dynamic-programming-in-visual-basic-10-0-and-c-4-0-lisa-feigenbaum.aspx"&gt;Some Dynamic Walkthroughs&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.codeplex.com/wikipage?ProjectName=IronPython"&gt;IronPython on CodePlex&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ironruby.net/"&gt;IronRuby&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f03%2fnew-article-by-bill-wagner-on-dynamic-method-bags.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f03%2fnew-article-by-bill-wagner-on-dynamic-method-bags.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9917015" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="Dynamic" scheme="http://blogs.msdn.com/charlie/archive/tags/Dynamic/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /></entry><entry><title>New Article on Detecting Memory Leaks . NET Applications</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/11/02/new-article-on-detecting-memory-leaks-net-applications.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/11/02/new-article-on-detecting-memory-leaks-net-applications.aspx</id><published>2009-11-02T23:49:40Z</published><updated>2009-11-02T23:49:40Z</updated><content type="html">&lt;p&gt;MSDN has published an excellent article by &lt;a href="http://proagora.com/en/experts/profiles/fabrice.marguerie"&gt;Fabrice Marguerie&lt;/a&gt; entitled “&lt;a href="http://msdn.microsoft.com/en-us/library/ee658248.aspx"&gt;How to Detect and Avoid Memory and Resource Leaks in .NET Applications&lt;/a&gt;.” In the article, the author explains how memory leaks are introduced into .NET applications, and what you can do to discover and eliminate them. The code shown in the article is in C#, but the topics covered will likely be useful to a broad range of .NET developers. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/NewArticleonDetectingMem.NETApplications_D88F/FabriceMarguerie_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="FabriceMarguerie" border="0" alt="FabriceMarguerie" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/NewArticleonDetectingMem.NETApplications_D88F/FabriceMarguerie_thumb.jpg" width="82" height="104" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Fabrice Marguerie is a Microsoft MVP, French Software Architect and Web Entrepreneur with an in-depth understanding of .NET technology.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Fabrice explains his subject in great depth, providing information that will be useful both to advanced developers, and to those with an intermediate-level understanding of .NET development. Features included in the text include:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;An explanation of how memory and resource leaks occur in .NET application &lt;/li&gt;    &lt;li&gt;A demonstration of how to detect those leaks &lt;/li&gt;    &lt;li&gt;A list of common causes of memory leaks and how to avoid them &lt;/li&gt;    &lt;li&gt;A useful reference section listing a number of tools that can be used to help you find and manage leaks &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;This is a well written article with a wealth of information in it. Hurry on over to the Dev Center and &lt;a href="http://msdn.microsoft.com/en-us/library/ee658248.aspx"&gt;take a look&lt;/a&gt;.&lt;/p&gt;  &lt;h2&gt;References&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ee658248.aspx"&gt;How to Detect and Avoid Memory and Resource Leaks in .NET Applications&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://proagora.com/fr/experts/profiles/fabrice.marguerie"&gt;Fabrice’s bio&lt;/a&gt; on proagora &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f02%2fnew-article-on-detecting-memory-leaks-net-applications.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f02%2fnew-article-on-detecting-memory-leaks-net-applications.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916466" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Visual Studio" scheme="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx" /></entry><entry><title>CSharp “How Do I Videos (Podcasts)” for the Zune Software</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/11/01/csharp-how-do-i-videos-for-the-zune-software.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/11/01/csharp-how-do-i-videos-for-the-zune-software.aspx</id><published>2009-11-01T20:54:40Z</published><updated>2009-11-01T20:54:40Z</updated><content type="html">&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;p&gt;It can be handy to create custom RSS feeds for the Zune so that it is easy to download and watch selected videos. You can watch these videos either on your PC, or on the Zune itself. &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;Here&lt;/a&gt; is a custom feed I created that contains all the new C# 4.0 language and IDE &lt;a href="http://msdn.microsoft.com/en-us/bb629407.aspx"&gt;How Do I Videos&lt;/a&gt;, plus a selection of other How Do I videos. In total, at this time, there are 35 videos in the feed. The RSS I created uses a simple and quite minimal syntax tested only with Internet Explorer 8 and the software for Zune 4.0.740.0. The source for the C# program that generated the feed includes regular expressions, LINQ to Objects and LINQ to SQL. I discuss that program briefly at the bottom of this post.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;Charlie’s Custom C# and Visual Studio Feed&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/bb629407.aspx"&gt;The How Do I Video Home Page with over 500 Videos&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;How Do Videos for &lt;a href="http://msdn.microsoft.com/en-us/vstudio/bb507746.aspx"&gt;Visual Studio&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;How Do I Videos for C#&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;Download the &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;source&lt;/a&gt; for this post from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ farm&lt;/a&gt;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You can use this custom feed from inside IE, as shown in Figure 0. However, I really created this feed to run on the Zune, so you should import the feed into the Zune software as a series of podcast. I explain this latter process in the next section of this post.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure00_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure00" border="0" alt="Figure00" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure00_thumb.png" width="644" height="471" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 0: Viewing a simple RSS feed in IE 8. Click the image to expand it.&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;Using the Feed in the Zune Software&lt;/h2&gt;  &lt;p&gt;In this section I provide a quick tutorial for those who’ve never used Podcasts with a Zune. Open &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;the custom RSS&lt;/a&gt; feed in IE and grab the URL from the address bar. Alternately, you can just right click on any of the links to the feed in this document and choose &lt;strong&gt;Copy Shortcut &lt;/strong&gt;or whatever the equivalent command is in Firefox or other browsers. Open the Zune software and turn to the &lt;strong&gt;Collection | Podcasts&lt;/strong&gt; page. Click the button on the bottom left of the page called &lt;strong&gt;Add a Podcast&lt;/strong&gt;. The &lt;strong&gt;Subscribe&lt;/strong&gt; dialog appears. Paste in the URL for the feed, as shown in Figure 1, and then click the &lt;strong&gt;Subscribe&lt;/strong&gt; button. The various How Do I podcasts included in the feed should begin downloading to your system, as shown in Figure 2.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure01_3.png" width="471" height="223" /&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Subscribing to an RSS Podcast feed in Zune Software 4.0.740.0&lt;/strong&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure02_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/CSharpHowDoIVideosfortheZuneSoftware_AB92/Figure02_thumb.png" width="644" height="317" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: Viewing a feed in the Zune Software.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You can then plug in your Zune and right click on the feed and choose to sync the videos to your device. I’ll confess, however, that many of these videos look best on a PC, since you need a certain amount of screen real estate to adequately view the code typed in by the presenters. &lt;/p&gt;  &lt;h2&gt;&lt;strong&gt;Creating the RSS Feed by Screen Scrapping&lt;/strong&gt;&lt;/h2&gt;  &lt;p&gt;I created this feed by the time honored hack of screen scraping. I first copied the URL for the home page of each video and passed it to C# code designed to download the HTML associated with the URL. The program parsed the HTML looking for the elements I needed in my feed. LINQ to XML provided a handy tool for creating my simple RSS feed. I simply passed in the data retrieved from the HTML file to a set of LINQ routines designed to produce the XML for an RSS feed. &lt;/p&gt;  &lt;p&gt;This technique is simple to implement.&amp;#160; Screen scraping is nevertheless a very brittle practice, as my code will last only so long as the basic structure of the HTML pages that I’m parsing remains static. How long such conditions will prevail one can only suppose.&lt;/p&gt;  &lt;p&gt;I called my quick and dirty program &lt;strong&gt;CreateRssFeed, &lt;/strong&gt;and its source is available for &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;download&lt;/a&gt;. The program is based on two custom classes, one for generating the RSS feed, the other for using Regular Expressions to parse the HTML file.&amp;#160; I store the URLs for the 35 HDI video pages in a file called &lt;strong&gt;UrlsToProcess.txt&lt;/strong&gt;. I won’t bore you with the complete listings for this code, but I show the main body in Listing 1, and a short excerpt from the RSS feed is shown in Listing 2. &lt;/p&gt;  &lt;p&gt;When you download the source, you will find versions for both VS 2008 and VS 2010, Beta 2. The latter solution contains both a console and a windows forms app. They each have their advantages, but I tend to prefer the former.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Listing 1: The main body of the program.&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:86edbd1a-51cc-4e41-8c27-625eb52e991e" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System.IO;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; CreateRssVideo.Code;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; CreateRssVideo&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ProgramConsole&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Main(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] args)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] urls = &lt;span style="color:#2b91af"&gt;File&lt;/span&gt;.ReadAllLines(&lt;span style="color:#a31515"&gt;&amp;quot;UrlsToProcess.txt&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt; items = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;ParseHdiVideoPages&lt;/span&gt; parser = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ParseHdiVideoPages&lt;/span&gt;(items);&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; url &lt;span style="color:#0000ff"&gt;in&lt;/span&gt; urls)&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;parser.ProcessUrl(url);&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;Console&lt;/span&gt;.WriteLine(items[items.Count-&lt;span style="color:#a52a2a"&gt;1&lt;/span&gt;]);&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#2b91af"&gt;File&lt;/span&gt;.WriteAllText(&lt;span style="color:#a31515"&gt;@&amp;quot;..&amp;#92;..&amp;#92;CSharpZuneReadyHowDoIVideos.rss&amp;quot;&lt;/span&gt;, parser.RetrieveXml());&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Listing 1: An abbreviated version of the RSS Feed created by the code for the CreateRssVideo program.&lt;/strong&gt;&lt;/p&gt;  &lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:afae1f2d-aa35-488e-b6cb-aa3a70ad7f2b" class="wlWriterEditableSmartContent"&gt; &lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt; &lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt; &lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt; &lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515"&gt;xml&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;standalone&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;yes&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000"&gt;Charlie&amp;#39;s RSS Feed for Videos&lt;/span&gt;&lt;span style="color:#0000ff"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;rss&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;2.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;channel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;CSharp How Do I Video Custom Feed for Zune Software&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;VS 2010 Related Videos&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;http://blogs.msdn.com/charlie&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;item&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;Add Tool Windows to the Visual Studio IDE?&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;title&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;This video demonstrates how to&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;description&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;http://msdn.microsoft.com/en-us/vstudio/dd250814.aspx&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;link&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;enclosure&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;url&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;http://download.microsoft.com/CreatingToolWindows.wmv&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;type&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt;video/x-ms-wmv&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;item&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;channel&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;rss&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;The C# code for the &lt;strong&gt;CreateRssVideo&lt;/strong&gt; program uses the build-in &lt;strong&gt;WebClient&lt;/strong&gt; object to download the HTML for the video home page as a string: &lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; RetrieveHtmlFromSite(&lt;span class="kwrd"&gt;string&lt;/span&gt; urlName)
{
    WebClient objWebClient = &lt;span class="kwrd"&gt;new&lt;/span&gt; WebClient();
    &lt;span class="kwrd"&gt;byte&lt;/span&gt;[] requestedUrl = objWebClient.DownloadData(urlName);
    UTF8Encoding utf8 = &lt;span class="kwrd"&gt;new&lt;/span&gt; UTF8Encoding();
    &lt;span class="kwrd"&gt;string&lt;/span&gt; htmlAsString = utf8.GetString(requestedUrl);
    &lt;span class="kwrd"&gt;return&lt;/span&gt; htmlAsString;
}&lt;/pre&gt;

&lt;p&gt;It then uses bits of Regular Expression code to parse the HTML and extract the title, description and video URL from it:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; FindStringInHtmlFile(&lt;span class="kwrd"&gt;string&lt;/span&gt; htmlAsString, &lt;span class="kwrd"&gt;string&lt;/span&gt; regEx)
{
    Regex r = &lt;span class="kwrd"&gt;new&lt;/span&gt; Regex(regEx, RegexOptions.IgnoreCase);

    MatchCollection matchCollection = r.Matches(htmlAsString);
    &lt;span class="kwrd"&gt;string&lt;/span&gt; groupItem = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;

    &lt;span class="kwrd"&gt;if&lt;/span&gt; (matchCollection.Count &amp;gt; 0)
    {
        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (Group groupItemFound &lt;span class="kwrd"&gt;in&lt;/span&gt; matchCollection[0].Groups)
        {
            groupItem = groupItemFound.Value;
        }
    }
    &lt;span class="kwrd"&gt;return&lt;/span&gt; groupItem;
}        &lt;/pre&gt;

&lt;p&gt;Below is a sample of one of the simple regular expressions that I pass into the &lt;strong&gt;FindStringInHtmlFile &lt;/strong&gt;method. This particular bit of code is used to retrieve the description of the video from the HTML file:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; regExDescriptionText = &lt;span class="str"&gt;@&amp;quot;([A-Z\s0-9#\.,\(\)\-]+)&amp;quot;&lt;/span&gt;;
&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; regExDescription = &lt;span class="str"&gt;@&amp;quot;&amp;lt;p&amp;gt;&amp;lt;strong&amp;gt;About this Video&amp;lt;/strong&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&amp;quot;&lt;/span&gt; + regExDescriptionText;&lt;/pre&gt;

&lt;p&gt;While we are parsing the HTML, the program works step by step to create the RSS document using LINQ to XML. The first stage in the RSS creation is to new-up an outline or shell that will hold the meat of the document:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Start()
{
    &lt;span class="kwrd"&gt;string&lt;/span&gt; link = &lt;span class="str"&gt;&amp;quot;http://blogs.msdn.com/charlie&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;string&lt;/span&gt; title = &lt;span class="str"&gt;&amp;quot;CSharp How Do I Video Custom Feed for Zune Software&amp;quot;&lt;/span&gt;;
    &lt;span class="kwrd"&gt;string&lt;/span&gt; description = &lt;span class="str"&gt;&amp;quot;VS 2010 Related Videos&amp;quot;&lt;/span&gt;;

    theDocument = &lt;span class="kwrd"&gt;new&lt;/span&gt; XDocument(&lt;span class="kwrd"&gt;new&lt;/span&gt; XDeclaration(&lt;span class="str"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;yes&amp;quot;&lt;/span&gt;),
        &lt;span class="kwrd"&gt;new&lt;/span&gt; XComment(&lt;span class="str"&gt;&amp;quot;Charlie's RSS Feed for Videos&amp;quot;&lt;/span&gt;),
        GetChannel(link, title, description));
}        

&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XElement GetChannel(&lt;span class="kwrd"&gt;string&lt;/span&gt; link, &lt;span class="kwrd"&gt;string&lt;/span&gt; title, &lt;span class="kwrd"&gt;string&lt;/span&gt; description)
{
    &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;rss&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;version&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;2.0&amp;quot;&lt;/span&gt;),
        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;channel&amp;quot;&lt;/span&gt;,
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, title),
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, description),
                        &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, link)));
}&lt;/pre&gt;

&lt;p&gt;The &lt;strong&gt;Start&lt;/strong&gt; method creates the document itself, including an XML declaration and a comment. The &lt;strong&gt;GetChannel&lt;/strong&gt; method adds a few simple fields to the document that describes its purpose and which list the URL for my home page. Compare this code with the first few lines from Listing 1 to be sure you understand its purpose. &lt;/p&gt;

&lt;p&gt;As the information for each HDI video is discovered, a new &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; node is created for the RSS feed. This node lists the title for the video, describes the video, and references the URL for the HTML page where the video is stored. Finally, and most importantly, the code includes the &lt;strong&gt;&amp;lt;enclosure&amp;gt;&lt;/strong&gt; node which stores the URL of the actual video. It is the &lt;strong&gt;&amp;lt;enclosure&amp;gt;&lt;/strong&gt; node that the Zune software uses to locate the video which it downloads to your system:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; XElement GetItem(&lt;span class="kwrd"&gt;string&lt;/span&gt; itemTitle, &lt;span class="kwrd"&gt;string&lt;/span&gt; description, &lt;span class="kwrd"&gt;string&lt;/span&gt; linkUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; videoUrl)
{
    XElement item = &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;item&amp;quot;&lt;/span&gt;,
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;title&amp;quot;&lt;/span&gt;, itemTitle),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;description&amp;quot;&lt;/span&gt;, description),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;, linkUrl),
                &lt;span class="kwrd"&gt;new&lt;/span&gt; XElement(&lt;span class="str"&gt;&amp;quot;enclosure&amp;quot;&lt;/span&gt;,
                    &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;url&amp;quot;&lt;/span&gt;, videoUrl), &lt;span class="kwrd"&gt;new&lt;/span&gt; XAttribute(&lt;span class="str"&gt;&amp;quot;type&amp;quot;&lt;/span&gt;, &lt;span class="str"&gt;&amp;quot;video/x-ms-wmv&amp;quot;&lt;/span&gt;)));
    &lt;span class="kwrd"&gt;return&lt;/span&gt; item;
}&lt;/pre&gt;

&lt;p&gt;Once the &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; node has been created, it is added to the XML document itself:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; AddItem(&lt;span class="kwrd"&gt;string&lt;/span&gt; itemTitle, &lt;span class="kwrd"&gt;string&lt;/span&gt; description, &lt;span class="kwrd"&gt;string&lt;/span&gt; linkUrl, &lt;span class="kwrd"&gt;string&lt;/span&gt; videoUrl)
{            
    XElement item = GetItem(itemTitle, description, linkUrl, videoUrl);            

    var linkNode = from x &lt;span class="kwrd"&gt;in&lt;/span&gt; theDocument.Descendants(&lt;span class="str"&gt;&amp;quot;link&amp;quot;&lt;/span&gt;)
                   select x;
    
    linkNode.First().AddAfterSelf(item);            
}&lt;/pre&gt;

&lt;p&gt;Note that this code includes a simple LINQ query used to discover the proper insertion point in the XML document, and then employs the LINQ to XML &lt;strong&gt;AddAfterSelf&lt;/strong&gt; operator to insert the new &lt;strong&gt;&amp;lt;item&amp;gt;&lt;/strong&gt; XML node into the code for the RSS feed. The program enters and loop and repeats the process of creating and inserting &lt;strong&gt;&amp;lt;item&amp;gt; &lt;/strong&gt;nodes into our RSS feed multiple times. Once all the URLs in our &lt;strong&gt;UrlsToProcess.txt&lt;/strong&gt; document have been examined the program exits.&lt;/p&gt;

&lt;h2&gt;Summary&lt;/h2&gt;

&lt;p&gt;The primary purpose of this post is to provide an RSS feed that you can use to download videos for viewing in the Zune software or in the Zune itself. I also showed a simple, and very brittle, screen scraping program that I used to create the feed. I wrote this program for my own use, and pass it on to you with only minimal claims of its value. If nothing else, it provides some examples of how to have fun writing Regular Expressions, and demonstrates how easy it is to use LINQ to Objects and LINQ to XML to create XML documents.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The &lt;a href="http://www.elvenware.com/charlie/rss/CSharpZuneReadyHowDoIVideos.rss"&gt;video feed&lt;/a&gt;. &lt;/li&gt;

  &lt;li&gt;The &lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7971"&gt;source&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LINQ farm&lt;/a&gt;. &lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f01%2fcsharp-how-do-i-videos-for-the-zune-software.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f11%2f01%2fcsharp-how-do-i-videos-for-the-zune-software.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9915933" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Visual Studio" scheme="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx" /><category term="Samples" scheme="http://blogs.msdn.com/charlie/archive/tags/Samples/default.aspx" /><category term="Video" scheme="http://blogs.msdn.com/charlie/archive/tags/Video/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /><category term="Web" scheme="http://blogs.msdn.com/charlie/archive/tags/Web/default.aspx" /></entry><entry><title>VSL at DevConnections</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/31/vsl-at-devconnections.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/31/vsl-at-devconnections.aspx</id><published>2009-10-31T08:38:02Z</published><updated>2009-10-31T08:38:02Z</updated><content type="html">&lt;p&gt;The following talks will be given by Visual Studio Languages team members at the &lt;a href="http://www.devconnections.com/"&gt;DevConnections&lt;/a&gt; Conference in Las Vegas. &lt;/p&gt; &lt;td&gt;  &lt;table border="2"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;th&gt;Tuesday, November 10, 2009&lt;/th&gt;        &lt;th&gt;Title&lt;/th&gt;        &lt;th&gt;Speaker&lt;/th&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;10:00am - 11:00am&lt;/td&gt;        &lt;td&gt;VMS01: The Future of C#&lt;/td&gt;        &lt;td&gt;Charlie Calvert&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;11:15am - 12:15pm&lt;/td&gt;        &lt;td&gt;VMS02: Future Directions for Visual Basic&lt;/td&gt;        &lt;td&gt;Jared Parsons&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;1:45pm - 2:45pm&lt;/td&gt;        &lt;td&gt;VMS03: Microsoft Visual C# IDE Tips and Tricks&lt;/td&gt;        &lt;td&gt;Charlie Calvert&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td&gt;3:15pm - 4:15pm&lt;/td&gt;        &lt;td&gt;VMS04: Microsoft Visual Basic IDE Tips and Tricks&lt;/td&gt;        &lt;td&gt;Jared Parsons&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;For additional Information see:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://www.devconnections.com/"&gt;DevConnections Home Page&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?s=136"&gt;Visual Studio Connections&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?c=2&amp;amp;s=136"&gt;Speakers&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?c=1&amp;amp;s=136"&gt;Sessions&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.devconnections.com/shows/FALL2009VS/default.asp?c=27&amp;amp;s=136"&gt;Schedule&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f31%2fvsl-at-devconnections.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f31%2fvsl-at-devconnections.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9915621" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Community" scheme="http://blogs.msdn.com/charlie/archive/tags/Community/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /><category term="Conferences" scheme="http://blogs.msdn.com/charlie/archive/tags/Conferences/default.aspx" /></entry><entry><title>Visual Studio 2010 Beta 2 does not Load: The “Application Cannot Start” and Raster Font Errors</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/29/visual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/29/visual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx</id><published>2009-10-29T22:13:43Z</published><updated>2009-10-29T22:13:43Z</updated><content type="html">&lt;p&gt;I was working at home the other night with a freshly installed copy of Visual 2010 Beta 2. I closed the IDE for a moment, and when I tried to reopen it, I got an error that read: “The application cannot start.” I found I could start the IDE by using the Jump Lists in Windows 7 to start a specific application rather than simply opening the IDE without loading a project. After getting back inside the development environment, I rummaged about for a bit and finally fixed the problem, probably by resetting my profile (&lt;strong&gt;Tools | Import Export Settings&lt;/strong&gt;). That may or may not work for you, but these two excellent and authoritative posts are more likely to solve your problem if you encounter a similar error:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/visualstudio/archive/2009/10/29/how-to-fix-the-application-cannot-start-error.aspx"&gt;How to fix the “Application Cannot Start” Error&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/visualstudio/archive/2009/10/27/VS-2010-Beta2_3A00_--Workaround-for-Raster-Font-Settings-Issue.aspx"&gt;Work around for the Raster Font Settings Issue&lt;/a&gt; (“Object reference not set to an instance of an object.”) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/TwoIssueswithVisualStudio2010Beta2TheApp_D481/ApplicationCannotStart_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="ApplicationCannotStart" border="0" alt="ApplicationCannotStart" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/TwoIssueswithVisualStudio2010Beta2TheApp_D481/ApplicationCannotStart_thumb.png" width="634" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: There is no joy in Mudville, Visual Studio 2010, Beta 2 will not start!&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I was having an excellent time working inside VS 2010 Beta 2, so I was frustrated to hit this glitch. I don’t want you to wander into the same troubled climes, so I’m posting here this good information from two experts on the VS IDE. By the way, these issues are all fixed in our new internal builds, and those fixes will be part of the final release of Visual Studio 2010.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f29%2fvisual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f29%2fvisual-studio-2010-beta-2-does-not-load-the-application-cannot-start-and-raster-fonts-errors.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9914988" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="Visual Studio" scheme="http://blogs.msdn.com/charlie/archive/tags/Visual+Studio/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /><category term="Beta Software" scheme="http://blogs.msdn.com/charlie/archive/tags/Beta+Software/default.aspx" /></entry><entry><title>A Chance to Influence the MSDN Visual Studio Documentation (Help System)</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/27/a-chance-to-influence-the-visual-studio-documentation.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/27/a-chance-to-influence-the-visual-studio-documentation.aspx</id><published>2009-10-27T21:43:37Z</published><updated>2009-10-27T21:43:37Z</updated><content type="html">&lt;p&gt;The docs team here at Microsoft has created a &lt;a href="http://go.microsoft.com/fwlink/?LinkID=102169"&gt;new survey&lt;/a&gt; to solicit your opinion on the help system found in the &lt;a href="http://msdn.microsoft.com/en-us/library/default.aspx"&gt;MSDN technical library&lt;/a&gt;. This the same information you see if you press F1 in Visual Studio to get help on the IDE or your development language. I know the people who create and process this survey, and I can assure that any feedback you give will be processed and carefully considered. The team is strongly driven by input from our users, and this is your chance to have your say. I’ve taken the survey myself, and found that it consists of about 10 pages with an average of 2 or 3 questions per page. I didn’t spend much time contemplating each question, and was therefore able to finish the survey in about 5 minutes.&lt;/p&gt;  &lt;h2&gt;Links&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;The Survey: &lt;a href="http://go.microsoft.com/fwlink/?LinkID=102169"&gt;http://go.microsoft.com/fwlink/?LinkID=102169&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/default.aspx"&gt;The MSDN Library&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd831853(VS.100).aspx"&gt;The MSDN Library page on Visual Studio 2010 Beta 2&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Thank you for your input!&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f27%2fa-chance-to-influence-the-visual-studio-documentation.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f27%2fa-chance-to-influence-the-visual-studio-documentation.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9913729" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="Community" scheme="http://blogs.msdn.com/charlie/archive/tags/Community/default.aspx" /><category term="Help System" scheme="http://blogs.msdn.com/charlie/archive/tags/Help+System/default.aspx" /></entry><entry><title>Running IronPython Scripts from a C# 4.0 Program</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/25/hosting-ironpython-in-a-c-4-0-program.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/25/hosting-ironpython-in-a-c-4-0-program.aspx</id><published>2009-10-26T06:41:52Z</published><updated>2009-10-26T06:41:52Z</updated><content type="html">&lt;p&gt;IronPython is a scripting language hosted on the .NET platform. This posts shows how you can use the &lt;a href="http://www.codeplex.com/dlr"&gt;Dynamic Language Runtime (DLR)&lt;/a&gt; and the new &lt;a href="http://code.msdn.microsoft.com/csharpfuture"&gt;C# 4.0&lt;/a&gt; &lt;strong&gt;dynamic&lt;/strong&gt; keyword to call an IronPython script from a C# program.&lt;/p&gt; &lt;p&gt;Before going any further, it might be helpful to take a moment to explore the architecture that makes this technology possible. The key building block is the DLR, which sits on top of the .NET 4.0 CLR and provides the tooling for adding dynamic programs such as Python to the family of .NET languages. C# 4.0 adds the &lt;strong&gt;dynamic&lt;/strong&gt; keyword and some related technologies to integrate support for dynamic binding into the language. The end result is that developers can arbitrary Python scripts directly from C# or other .NET languages.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7927"&gt;Download Source&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LinqFarm&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Setting up a C# Project to Call IronPython&lt;/h2&gt; &lt;p&gt;In two previous posts I described how to install and run a simple IronPython program:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/22/ironruby-and-ironpython-for-net-4-0-beta-2-available.aspx"&gt;Announcing IronPython and IronRuby releases for Visual Studio 2010 Beta 2&lt;/a&gt;  &lt;li&gt;&lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/25/running-ironpython.aspx"&gt;Getting Started with IronPython&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;If you don’t already have the latest version of IronPython installed or if you need a little refresher course in writing Python scripts, then you might want to glance at these posts. Otherwise, you can just keep reading to learn how to call Python from C#.&lt;/p&gt; &lt;p&gt;After the IronPython installation, its interpreter and its libraries will be installed in your &lt;strong&gt;Program Files&lt;/strong&gt; directory, as shown in Listing 1. The interpreter is installed in &lt;strong&gt;ipy.exe&lt;/strong&gt;, where ipy is pronounced “Eye-Pie.” The interpreter remains dormant when you call Python from C#, so our focus here should be on the assemblies shown in the second half of the listing, with a particular emphasis on &lt;strong&gt;IronPython.dll&lt;/strong&gt;.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Listing 1: At the command prompt you can easily see the core files that form the basis for the IronPython installation.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2&amp;gt;dir *.exe *.dll
 Volume in drive C has no label.
 Volume Serial Number is 4C6B-EE0E

 Directory of C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2

10/18/2009  01:47 PM            12,624 ipy.exe
10/18/2009  01:47 PM            12,624 ipyw.exe

 Directory of C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2

10/18/2009  01:47 PM         1,433,424 IronPython.dll
10/18/2009  01:47 PM           435,536 IronPython.Modules.dll
10/18/2009  01:47 PM           875,856 Microsoft.Dynamic.dll
10/18/2009  01:47 PM            58,192 Microsoft.Scripting.Debugging.dll
10/18/2009  01:47 PM           159,056 Microsoft.Scripting.dll
               7 File(s)      2,987,312 bytes
               0 Dir(s)  16,881,614,848 bytes free&lt;/pre&gt;
&lt;p&gt;To run a Python script inside a C# program, you should include some or all of the libraries shown in Listing 1 in the &lt;strong&gt;References&lt;/strong&gt; section of your project. To get started, choose&lt;strong&gt; File | New Project (Ctrl-Shift-N)&lt;/strong&gt; from the &lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Visual Studio 2010&lt;/a&gt; menu and create a new console application. Then open the &lt;strong&gt;Solution Explorer (Ctrl-W, S)&lt;/strong&gt; and go to the &lt;strong&gt;References&lt;/strong&gt; section for your project. Right click and choose&lt;strong&gt; Add Reference.&lt;/strong&gt; Take a moment to appreciate how quickly the &lt;strong&gt;Add References&lt;/strong&gt; dialog appeared (the team worked hared on this performance improvement), and then select the &lt;strong&gt;Browse&lt;/strong&gt; tab and navigate to the directory where IronPython resides. The path to the directory hosting IronPython will probably be similar to the one shown in Listing 1. For now, the simplest choice is to select all the assemblies found in that directory, as shown in Figure 1. If you wish to keep things simple, then you only need to select &lt;strong&gt;IronPython.dll, Microsoft.Dynamic.dll&lt;/strong&gt; and &lt;strong&gt;Microsoft.Scripting.dll &lt;/strong&gt;to compile and run the program shown in this example.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_147F2/Figure01_6.png" width="486" height="412"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 1: Using the &lt;em&gt;&lt;u&gt;Add References&lt;/u&gt;&lt;/em&gt; dialog to select the assemblies found in that directory.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When you are done, the IronPython libraries should appear in the &lt;strong&gt;References&lt;/strong&gt; section of the &lt;strong&gt;Solution Explorer&lt;/strong&gt;, as shown in Figure 2.&lt;/p&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02" border="0" alt="Figure02" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_147F2/Figure02_3.png" width="286" height="410"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 2: The References node of the Solution Explorer for a C# program that calls an IronPython script.&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Writing the Code for Calling IronPython&lt;/h2&gt;
&lt;p&gt;Now that you have your project set up correctly you need to do two things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write or find a script containing Python code that you want to run 
&lt;li&gt;Write C# code to call the script. &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Listing 2 shows a very simple IronPython script that contains a single method called &lt;strong&gt;Simple() &lt;/strong&gt;that writes a few strings to a console window. Save this script to a file called Test.py, and add it to your project, as shown in Figure 2. There are several ways to do this. One is to right click on your project in the Solution Explorer, and choose &lt;strong&gt;Add | New Item. &lt;/strong&gt;Add a text file, and call it &lt;strong&gt;Test.py&lt;/strong&gt;. Click on the new node when it is added to your project, and set its &lt;strong&gt;Copy to Output Directory&lt;/strong&gt; property to &lt;strong&gt;Copy Always. &lt;/strong&gt;If the Properties window is not visible, you can bring it up by selecting Ctrl-W, P.&lt;/p&gt;
&lt;p&gt;Listings 3a and 3b show the C# code for calling the script, and Listing 4 shows the output from the C# program that hosts the script.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 2: A Simple Python script stored in a file called Test.py. This code prints out some basic information about the environment in which Python is running.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;import sys

def Simple():
	print "Hello from Python"
	print "Call Dir(): "
	print dir()
	print "Print the Path: " 
	print sys.path&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Listing 3a: A simple C# program for calling a Python script&lt;/strong&gt;&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:582600b1-95f9-44b5-a83f-01d23c2d1477" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px"&gt;Code Snippet&lt;/div&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt;
&lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; System;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; IronPython.Hosting;&lt;/li&gt;
&lt;li&gt;&lt;span style="color:#0000ff"&gt;using&lt;/span&gt; Microsoft.Scripting.Hosting;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;dynamic_demo&lt;/span&gt;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;{&lt;/li&gt;
&lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Main()&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;{&lt;/li&gt;
&lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; ipy = &lt;span style="color:#2b91af"&gt;Python&lt;/span&gt;.CreateRuntime();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style="color:#0000ff"&gt;dynamic&lt;/span&gt; test = ipy.UseFile(&lt;span style="color:#a31515"&gt;&amp;quot;Test.py&amp;quot;&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;test.Simple();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;}&lt;/li&gt;
&lt;li&gt;}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Listing 3b: The same C# program shown in Listing 3a, but this presentation is easier for you to block copy into your own version of the program.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;using System;
using IronPython.Hosting;
using Microsoft.Scripting.Hosting;

public class dynamic_demo
{
    static void Main()
    {
        var ipy = Python.CreateRuntime();
        dynamic test = ipy.UseFile("Test.py");
        test.Simple();
    }
}&lt;/pre&gt;
&lt;p&gt;The code in Listing 2 is a very simple Python script. Before calling it from C#, you might want to see it in action. That way you can be sure the script works and you can verify what the script is supposed to do. To get started, block copy the code in Listing 2. Use the Windows Start Menu to open up the Python Console window and paste in the code. Finally, you should explicitly call the &lt;strong&gt;Simple()&lt;/strong&gt; method, as shown in Figure 3. When looking at this screen shot, you can see the version of the Python Console on the first two lines. The next 8 lines show the code that I pasted into the console. Finally, you see where I typed in the call to &lt;strong&gt;Simple(),&lt;/strong&gt; and after that the output from the script. Once again, this has nothing to do with calling the code from C#, it is just a way of verifying that you have a valid script, and of confirming how it should perform.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_AB98/Figure03_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure03" border="0" alt="Figure03" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_AB98/Figure03_thumb.png" width="644" height="327"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 3: A screenshot showing a run of the Python script that we will be calling from our C# program.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now let’s look at the 3 lines of code used to call this script from a C# program. This code is shown in Listings 3a and 3b. It first creates an instance of the Python runtime, as shown in line 9:&lt;/p&gt;&lt;pre class="myclass"&gt;var ipy = Python.CreateRuntime();&lt;/pre&gt;
&lt;p&gt;The call to &lt;strong&gt;CreateRunTime&lt;/strong&gt; loads or sets up the core Python libraries and the &lt;a href="http://www.codeplex.com/dlr"&gt;DLR code&lt;/a&gt; needed to to execute the Python script. The second line of code, found on line 10, calls &lt;strong&gt;UseFile&lt;/strong&gt; to load our simple Python script into memory. Notice that the result of this call is a &lt;strong&gt;dynamic&lt;/strong&gt; object. The &lt;strong&gt;dynamic&lt;/strong&gt;&amp;nbsp; keyword is a new feature in C# 4.0 and Visual Studio 2010 which tells the compiler to resolve this particular call not at compile time, but at runtime.&lt;/p&gt;
&lt;p&gt;It’s very important to understand that the dynamic keyword breaks the strong type checking that has always been a hallmark of C# development. There is no doubt that the ability to call dynamic objects is a useful and important feature. However, it should be used sparingly since it sidesteps the strict type checking that makes C# such a powerful and useful language.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;dynamic&lt;/strong&gt; keyword is needed here because Python is an interpreted scripting language where calls are bound at run time, not at compile time. There is no simple or practical way to bind calls to Python at compile time because Python is designed to be a dynamic language which is resolved at runtime. Since C# is a strongly typed language it expects to resolve calls at compile time with strict type checking. In short, we are at an impasse. C# binds statically at compile time, Python dynamically at runtime. Something has to give, and the only valid solution was for C# to allow runtime binding for method calls. &lt;/p&gt;
&lt;p&gt;It is important to grasp that calls into Python are not strictly type checked at compile time, and are therefore not guaranteed to succeed at runtime. Just because your program compiled without error does not mean that you have properly bound each call in your program. In this case we call the method named &lt;strong&gt;Simple()&lt;/strong&gt;, which does in fact exist. As a result, the call succeeds, as shown by the output from the program found in Listing 4. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 4: The output from the C# program which calls a Python script.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;Hello from Python
Call Dir():
[]
Print the Path:
['.', 'C:\\Users\\Charlie\\Documents\\SyncData\\Source\\ProjectsShared\\Python\\CallPython\\CallPython\\bin\\Debug\\Lib', 
'C:\\Users\\Charlie\\Documents\\SyncData\\Source\\ProjectsShared\\Python\\CallPython\\CallPython\\bin\\Debug\\DLLs']
Press any key to continue . . .&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;Listing 4 shows the good side of working with dynamic code. Now let’s take a moment to consider the dark side. Suppose we called a method on our dynamic test class that does not exist. For the sake of argument, let’s call the method &lt;strong&gt;NonexistentMethod(),&lt;/strong&gt; which is shown in Listing 5. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 5: This code contains a call to a method called NonexistentMethod() that does not exist in our Test.py file. As a result, the call will fail at runtime.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt; var ipy = Python.CreateRuntime();
dynamic test = ipy.UseFile("Test.py");
test.Simple();            // Succeeds
test.NonexistentMethod(); // Fails&lt;/pre&gt;
&lt;p&gt;The code in Listing 5 contains a call to the method &lt;strong&gt;Simple()&lt;/strong&gt; that will succeed, since the Python script shown in Listing 2 does contain a method called &lt;strong&gt;Simple()&lt;/strong&gt;. However, the call to the method &lt;strong&gt;NonexistentMethod()&lt;/strong&gt; will raise an exception at runtime. This happens because the call cannot be resolved at runtime. At compile time, however, the compiler knows nothing about the object called &lt;strong&gt;test&lt;/strong&gt;. It makes no attempt to see whether or not the call will succeed. It simply takes your word for it and allows the compilation to succeed. At runtime, however, the error raises its head, as shown in Figure 4 and Listing 6.&lt;/p&gt;
&lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure03a" border="0" alt="Figure03a" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/HostingIronPythoninaC4.0Program_147F2/Figure03a_3.png" width="456" height="256"&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Figure 4: The exception raised inside the IDE at runtime when you attempt to call a method that does not exist.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Listing 6: The details of the exception that you receive at runtime when you attempt to call a method that does not exist.&lt;/strong&gt;&lt;/p&gt;&lt;pre class="myclass"&gt;Microsoft.CSharp.RuntimeBinder.RuntimeBinderException was unhandled
  Message='Microsoft.Scripting.Hosting.ScriptScope' does not contain a definition for 'NonexistentMethod'
  Source=Anonymously Hosted DynamicMethods Assembly
  StackTrace:
       at CallSite.Target(Closure , CallSite , Object )
       at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0](CallSite site, T0 arg0)
       at dynamic_demo.Main() in C:\Users\Charlie\Documents\SyncData\Source\ProjectsShared\Python\CallPython\CallPython\Program.cs:line 12
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
&lt;/pre&gt;
&lt;p&gt;The team went to lengths to ensure that the error you get at runtime looks almost exactly like the error you would have received at compile time had you attempted to call a static method that did not exist. Everything possible is done to make this experience easy for your to understand and handle, including giving you an exception that you can catch with your own custom code. &lt;/p&gt;
&lt;p&gt;It goes without saying that everyone on the Visual Studio Languages team at Microsoft understands the implications of introducing the &lt;strong&gt;dynamic&lt;/strong&gt; keyword into the C# language. We understand completely the advantages of statically linked code, and believe that strict type checking is a powerful tool that helps developers create robust code. In most cases, you should still use statically linked calls in your program. There are, however, scenarios that cannot be efficiently supported from the C# language without the introduction of dynamic programming. One is calling a dynamic language such as Python, and another is calling into a some COM objects, such as those used in those used by Microsoft Office. In order to make it easy for you to use dynamic languages and to perform COM Interop, the dynamic keyword was introduced into the C# 4.0 language, and the DLR became a built-in extension of .NET 4.0. Use these tools judiciously, and they will be your friend. Abuse them, and you are on your own.&lt;/p&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;p&gt;In this article you learned how to call a simple Python script from a C# application. You saw how to set up the &lt;strong&gt;References&lt;/strong&gt; section for your program so that it contains the assemblies used when calling an IronPython script. You then saw how to write a simple Python script, and how to call it from a C# program.&lt;/p&gt;
&lt;p&gt;The dynamic technology on display in this example makes use of a body of code called the DLR, or Dynamic Language Runtime. The &lt;strong&gt;dynamic&lt;/strong&gt; keyword that is part of C# 4.0 provides supports when you call dynamic languages or COM objects, and particularly when you use C# 4.0 to call into Microsoft Office applications. Coverage of calling into Office is separate subject, and will be covered in another post. A third topic deserving of coverage is using the &lt;strong&gt;dynamic&lt;/strong&gt; keyword in scenarios where you previously used reflection. &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=linqfarm&amp;amp;DownloadId=7927"&gt;Download Source&lt;/a&gt; from the &lt;a href="http://code.msdn.microsoft.com/linqfarm"&gt;LinqFarm&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2fhosting-ironpython-in-a-c-4-0-program.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2fhosting-ironpython-in-a-c-4-0-program.aspx"&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9912809" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Dynamic" scheme="http://blogs.msdn.com/charlie/archive/tags/Dynamic/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /><category term="Python" scheme="http://blogs.msdn.com/charlie/archive/tags/Python/default.aspx" /></entry><entry><title>Getting Started with IronPython</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/25/running-ironpython.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/25/running-ironpython.aspx</id><published>2009-10-26T01:03:46Z</published><updated>2009-10-26T01:03:46Z</updated><content type="html">&lt;style type="text/css"&gt;









 	pre.myclass {color:black; background:lightgray}
 &lt;/style&gt;  &lt;p&gt;I recently spent some time getting IronPython up and running on my system; I will review what I learned in this post. &lt;/p&gt;  &lt;p&gt;Hosted inside an interpreter, Python belongs to the same family of scripting tools as VBScript, JavaScript, Perl and Ruby. You can fairly compare Python to a general purpose language such as C#. Developers praise this loosely typed, dynamic language for its ease of use and rapid development capabilities. IronPython is Microsoft’s free version of the open source &lt;a href="http://www.python.org/"&gt;Python language&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;IronPython can be hosted inside a C# program as a scripting language. Nonetheless, Python is a powerful standalone language frequently used as the glue in web based applications. Before I came to work for Microsoft I enjoyed using it as part of my daily toolkit.&lt;/p&gt;  &lt;p&gt;In this post I explore the simple steps needed to run IronPython as a standalone tool from the command prompt. In other posts I will show how to call Python from inside a C# application.&lt;/p&gt;  &lt;h2&gt;Installing Python&lt;/h2&gt;  &lt;p&gt;I started by &lt;a href="http://blogs.msdn.com/charlie/archive/2009/10/22/ironruby-and-ironpython-for-net-4-0-beta-2-available.aspx"&gt;downloading IronPython&lt;/a&gt; from &lt;a href="http://www.codeplex.com/"&gt;CodePlex&lt;/a&gt; and installing it. The whole process from first visit to the IronPython web site until IronPython was installed probably took me little more than a minute. Below are the links to retrieve the code. If you are reading this article in 2009 or early 2010, consider using the first link, if the date is later than that then use the second link and look for a newer release:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125"&gt;The Beta 2 Release of IronPython&lt;/a&gt; (2.6 CTP for .NET 4.0 Beta 2) &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ironpython.codeplex.com/"&gt;IronPython Site&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Download the IronPython MSI Windows install file, then double click on it to run setup. When you are done, your IronPython installation will probably be located in a directory similar to this one:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;C:\Program Files (x86)\IronPython 2.6 CTP for .NET 4.0 Beta 2&lt;/strong&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Once you have the IronPython interpreter installed, you need to follow these steps to run a sample program:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Put IronPython on your Path &lt;/li&gt;    &lt;li&gt;Create an IronPython program &lt;/li&gt;    &lt;li&gt;Compile and run the program. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;In the next few sections of this post I’ll walk you through these steps. When you are done, you will have IronPython up and running on your system.&lt;/p&gt;  &lt;h2&gt;Setting Up Your Path&lt;/h2&gt;  &lt;p&gt;You can run IronPython from inside Visual Studio, but the tools for doing so are still primitive. Most Python developers work inside a lightweight editor and run Python from inside the IronPython interpreter or from the command line. This post focuses on building Python from the command line. To get started with that process, you will probably want to begin by ensuring that the IronPython interpreter is on your System Path. &lt;/p&gt;  &lt;p&gt;They say there must be fifty ways to set &lt;a href="http://technet.microsoft.com/en-us/library/cc753427(WS.10,loband).aspx#BKMK_examples"&gt;the system path&lt;/a&gt;. In this post I will outline two of them as practiced by developers on Vista or Windows 7. In both cases you can begin with a four step process to bring up the &lt;strong&gt;Environment Variables Dialog&lt;/strong&gt;:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Method One      &lt;ul&gt;       &lt;li&gt;Press the Windows Key to bring up the Start Menu &lt;/li&gt;        &lt;li&gt;Right click on &lt;strong&gt;Computer&lt;/strong&gt; and choose &lt;strong&gt;Properties&lt;/strong&gt; &lt;/li&gt;        &lt;li&gt;Click &lt;strong&gt;Advanced Computer Settings&lt;/strong&gt; &lt;/li&gt;        &lt;li&gt;Click &lt;strong&gt;Environment&lt;/strong&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;Method Two      &lt;ul&gt;       &lt;li&gt;Press the Windows Key to ring up the Start Menu &lt;/li&gt;        &lt;li&gt;Type &lt;strong&gt;Control Panel&lt;/strong&gt; and press enter &lt;/li&gt;        &lt;li&gt;You should be taken automatically to the search box on the top right of the control panel, if not, press Ctrl-E to get there and type &lt;strong&gt;Environment. &lt;/strong&gt;(The first three letters should be all that’s necessary) &lt;/li&gt;        &lt;li&gt;Hit tab twice to select &lt;strong&gt;Edit Environment Variables&lt;/strong&gt;, and then hit enter. &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Which ever technique you use, the dialog shown in Figure 1 should appear. You can use this dialog to edit the system path. &lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01" border="0" alt="Figure01" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/RunningIronPython_D2FC/Figure01_3.png" width="398" height="440" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: In this screenshot, a variable called Path has been added to the list of User Variables. It lists the path to the IronPython Interpreter.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Once the dialog appears, click New (Alt-N) to add a &lt;strong&gt;Path&lt;/strong&gt; variable for your account. A small dialog appears. Paste the path to IronPython into this dialog and click the OK button. The path should be similar to the path shown above which points to the directory where IronPython was installed. Click OK to close the Environment Variables dialog. From now on, and Command prompt window that you open should have an environment automatically set up to point to the IronPython interpreter. To test that everything is working correctly, go to the command prompt and type &lt;strong&gt;ipy&lt;/strong&gt;. If everything has gone well, you should see a result like the following. &lt;/p&gt;  &lt;pre class="myclass"&gt;C:\Users\Charlie\Documents\Python\PythonPost&amp;gt;ipy
IronPython 2.6 (2.6.10920.0) on .NET 4.0.21006.1
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
&amp;gt;&amp;gt;&amp;gt; exit()&lt;/pre&gt;

&lt;p&gt;As shown above, you can type&lt;strong&gt; exit()&lt;/strong&gt; and then &lt;strong&gt;enter&lt;/strong&gt; to quit the interpreter. You can also execute Python code from inside the interpreter. Working interactively inside the interpreter is a useful and powerful way to write code, but I will not cover it in this post.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Create a Python Program&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Now that you have Python on your path, you can easily compile your projects from the command line. Depending on your tastes, you can edit your program in Visual Studio, in NotePad, or in &lt;a href="http://notepad-plus.sourceforge.net/"&gt;NotePad++&lt;/a&gt;. The goal is to create a simple text-based source file with the letters py as an extension. Here, for example, is the complete contents of a simple Python source file:&lt;/p&gt;

&lt;pre class="myclass"&gt;&lt;font color="#0000ff"&gt;print&lt;/font&gt; &amp;quot;Very Simple Test&amp;quot;&lt;/pre&gt;

&lt;p&gt;You can save this source file as &lt;strong&gt;VerySimpleTest.py&lt;/strong&gt;, and process and run it by passing its name to the Python interpreter. The interpreter will process and run the program:&lt;/p&gt;

&lt;pre class="myclass"&gt;C:\Users\Charlie\Documents\Python\PythonPost&amp;gt;ipy VerySmipleTest.py.
Very Simple Test&lt;/pre&gt;

&lt;p&gt;Now that you understand the basics, the next step is to understand how to create functions, classes and multiple module projects. &lt;/p&gt;

&lt;p&gt;Python uses indentation rather than keywords or syntax to define blocks of code. Here, for instance, is how to define a function in Python:&lt;/p&gt;

&lt;pre class="myclass"&gt;def WriteTest():
	print &amp;quot;This is a test&amp;quot;&lt;/pre&gt;

&lt;p&gt;The keyword &lt;strong&gt;def&lt;/strong&gt; followed by a name and a colon defines the header for the function. The next line begins with tab character. This defines the beginning of main block for the function, which in this case contains a single line of code. If you had multiple lines in the function, then you would indent each line with a tab character. An empty line defines the end of the function.&lt;/p&gt;

&lt;p&gt;To define a class, you repeat the same process, but use the keyword &lt;strong&gt;class&lt;/strong&gt; rather than &lt;strong&gt;def&lt;/strong&gt;:&lt;/p&gt;

&lt;pre class="myclass"&gt;class SimpleLocalClass:
	def SimpleMethod(self):
		print &amp;quot;Simple Local Class&amp;quot;&lt;/pre&gt;

&lt;p&gt;Here you see the definition for a class called &lt;strong&gt;SimpleLocalClass&lt;/strong&gt; which has a single method called &lt;strong&gt;SimpleMethod&lt;/strong&gt;. Not everyone likes the Python syntax for defining classes and methods, but I have found intuitive and easy to use. &lt;/p&gt;

&lt;p&gt;Listings 1 and 2 contain a project with two files that demonstrates how to use functions and classes in Python:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Listing 1: Here is the main module for the project. It is a simple source file called &lt;u&gt;&lt;em&gt;Project.py&lt;/em&gt;&lt;/u&gt; containing a function and a simple class. This source file also has a dependency on a class called &lt;em&gt;&lt;u&gt;SimpleClassTest&lt;/u&gt;&lt;/em&gt; that is shown in Listing 2&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="myclass"&gt;from SimpleClass import SimpleClassTest

class SimpleLocalClass:
	def SimpleMethod(self):
		print &amp;quot;Simple Local Class&amp;quot;

def WriteTest():
	print &amp;quot;This is a test&amp;quot;
	
WriteTest()

simpleLocalClass = SimpleLocalClass()
simpleLocalClass.SimpleMethod()

simpleClass = SimpleClassTest()
simpleClass.SimpleMethod()	&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Listing 2: The second file in this project is called &lt;/strong&gt;&lt;u&gt;&lt;em&gt;SimpleClass.py&lt;/em&gt;&lt;/u&gt;&lt;strong&gt;. The file shown in Listing 1 depends on this class.&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="myclass"&gt;class SimpleClassTest:
	def SimpleMethod(self):
		print &amp;quot;Simple Class&amp;quot;&lt;/pre&gt;

&lt;p&gt;Notice the &lt;strong&gt;from&lt;/strong&gt; statement at the top of Listing 1. It is used to import the class found in Listing 2. I should also point out that there is no &lt;strong&gt;main()&lt;/strong&gt; method shown in listing 1. The word &lt;strong&gt;main&lt;/strong&gt; does not have the same significance in Python that it does in C#. The entry point for this Python program is the last set of un-indented statements found in &lt;strong&gt;Project.py&lt;/strong&gt;&lt;strong&gt;. &lt;/strong&gt;In this case the entry point begins with the call to &lt;strong&gt;WriteTest().&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Compiling and Running the Program&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Now that you have the two source files for your project, all you need do is compile and run them. The Python interpreter is designed to make this task as simple as possible. You need only reference the primary file for your project, the interpreter is smart enough to to parse the &lt;strong&gt;from&lt;/strong&gt; import statement at the top of Listing 1 and figure out from that how to include &lt;strong&gt;SimpleClass.py&lt;/strong&gt; in the project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Listing 3: Here is the command to process and run the files shown in Listings 1 and 2. The output from the command is also shown.&lt;/strong&gt;&lt;/p&gt;

&lt;pre class="myclass"&gt;C:\Users\Charlie\Python\PythonPost&amp;gt;ipy Project.py
This is a test
Simple Local Class
Simple Class&lt;/pre&gt;

&lt;h2&gt;Summary &lt;/h2&gt;

&lt;p&gt;In this post I have reviewed how to download and install IronPython, and how to get some simple Python scripts up and running on your system. You saw how to run a simple program from the command line, how to create:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A simple function&lt;/li&gt;

  &lt;li&gt;A simple class&lt;/li&gt;

  &lt;li&gt;And a mutli-module project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In future posts I will focus on calling IronPython from a C# program.&lt;/p&gt;
&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2frunning-ironpython.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f25%2frunning-ironpython.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9912728" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Dynamic" scheme="http://blogs.msdn.com/charlie/archive/tags/Dynamic/default.aspx" /><category term="Python" scheme="http://blogs.msdn.com/charlie/archive/tags/Python/default.aspx" /></entry><entry><title>New Video on Sharepoint and C# by Kathleen McGrath</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/22/new-videos-on-sharepoint-and-c-by-kathleen-mcgrath.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/22/new-videos-on-sharepoint-and-c-by-kathleen-mcgrath.aspx</id><published>2009-10-22T20:24:09Z</published><updated>2009-10-22T20:24:09Z</updated><content type="html">&lt;p&gt;Microsoft guru Kathleen McGrath has created an elegant and informative new video on SharePoint features found in Visual Studio 2010, Beta 2. In the video programming writer Norm Estabrook demonstrates how to create a model for the &lt;a href="http://msdn.microsoft.com/en-us/library/ee231515(VS.100).aspx"&gt;Business Data Connectivity&lt;/a&gt; service that returns information about contacts in a sample database. You can read Kathleen’s post on the interview or zoom directly to Channel 9 to view it.&lt;/p&gt;  &lt;h2&gt;Links&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blogs.msdn.com/kathleen/archive/2009/10/21/creating-an-external-list-in-sharepoint-by-using-business-data.aspx"&gt;Kathleen's Post on the Video&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://channel9.msdn.com/posts/kmcgrath/Creating-an-External-List-in-SharePoint-by-Using-Business-Data/"&gt;The Channel 9 Page for the Video&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Read about the &lt;a href="http://msdn.microsoft.com/en-us/library/ee231515(VS.100).aspx"&gt;Business Data Connectivity&lt;/a&gt; service &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f22%2fnew-videos-on-sharepoint-and-c-by-kathleen-mcgrath.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f22%2fnew-videos-on-sharepoint-and-c-by-kathleen-mcgrath.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911664" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author></entry><entry><title>IronRuby and IronPython for .NET 4.0 Beta 2 Available</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/22/ironruby-and-ironpython-for-net-4-0-beta-2-available.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/22/ironruby-and-ironpython-for-net-4-0-beta-2-available.aspx</id><published>2009-10-22T19:45:17Z</published><updated>2009-10-22T19:45:17Z</updated><content type="html">&lt;p&gt;The third preview of IronRuby and IronPython running under &lt;a href="http://dlr.codeplex.com/"&gt;the Dynamic Language Runtime&lt;/a&gt; and .NET 4.0 is now available. You can easily use IronPython and IronRuby objects and types as .NET 4.0 dynamic objects from within the pre-release versions of C# 4.0 and Visual Basic 10.0 found in Visual Studio 2010. The IronRuby and IronPython binaries are roughly equivalent to the functionality found in IronRuby 0.9 and IronPython 2.6. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/IronRubyandIronPythonfor.0Beta2Available_B35B/clip_image002_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" hspace="12" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/IronRubyandIronPythonfor.0Beta2Available_B35B/clip_image002_thumb.jpg" width="225" height="195" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Links&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://blog.jimmy.schementi.com/2009/10/ironruby-and-ironpython-ctps-for-net-40.html"&gt;Announcement&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=28125"&gt;IronPython&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33305"&gt;IronRuby&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Build IronPython from source: &lt;a href="http://ironpython.codeplex.com/SourceControl/ListDownloadableCommits.aspx"&gt;CodePlex&lt;/a&gt; (Use v4) &lt;/li&gt;    &lt;li&gt;Build IronRuby from source: &lt;a href="http://github.com/ironruby/ironruby"&gt;GitHub&lt;/a&gt; (&lt;a href="http://github.com/ironruby/ironruby/zipball/master"&gt;direct download&lt;/a&gt;) (Use v4) &lt;/li&gt;    &lt;li&gt;A&amp;#160; &lt;a href="http://devhawk.net/2009/10/21/IronPython+And+IronRuby+CTPs+For+NET+40+Beta+2.aspx"&gt;post about this release&lt;/a&gt; was created by &lt;a href="http://devhawk.net"&gt;Harry Pierson&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Install NET 4.0 Beta 2 or Visual Studio 2010 Beta 2&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/vbteam/archive/2008/12/17/walkthrough-dynamic-programming-in-visual-basic-10-0-and-c-4-0-lisa-feigenbaum.aspx"&gt;Dynamic walkthroughs&lt;/a&gt; online.       &lt;p&gt;&lt;/p&gt;   &lt;/li&gt; &lt;/ul&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f22%2fironruby-and-ironpython-for-net-4-0-beta-2-available.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f22%2fironruby-and-ironpython-for-net-4-0-beta-2-available.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9911641" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="Dynamic" scheme="http://blogs.msdn.com/charlie/archive/tags/Dynamic/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /></entry><entry><title>Community Convergence LVI</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/10/19/community-convergence-lvi.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/10/19/community-convergence-lvi.aspx</id><published>2009-10-19T20:21:00Z</published><updated>2009-10-19T20:21:00Z</updated><content type="html">&lt;P&gt;Welcome to the fifty-sixth community convergence. As you probably know by now, &lt;A href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"&gt;Visual Studio 2010 Beta 2&lt;/A&gt; has been released on MSDN and will be available to the general public on Wednesday, October 21, 2009. I’ve worked with the team to create a wide range of technical material designed to support this release, and I will call out each item out here in this post. Be sure to check out the new &lt;A href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/bb798022.aspx"&gt;How Do I&lt;/A&gt; and &lt;A href="http://channel9.msdn.com/posts/CharlieCalvert/CSharp-4-Dynamic-with-Chris-Burrows-and-Sam-Ng/" mce_href="http://channel9.msdn.com/posts/CharlieCalvert/CSharp-4-Dynamic-with-Chris-Burrows-and-Sam-Ng/"&gt;Interview&lt;/A&gt; videos, the &lt;A href="http://code.msdn.microsoft.com/csharpfuture" mce_href="http://code.msdn.microsoft.com/csharpfuture"&gt;samples&lt;/A&gt;, and the great posts by &lt;A href="http://blogs.msdn.com/csharpfaq/" mce_href="http://blogs.msdn.com/csharpfaq/"&gt;Alexandra Rusina&lt;/A&gt;. In other news, we’ve gotten word that the &lt;A href="http://www.socalcodecamp.com/" mce_href="http://www.socalcodecamp.com/"&gt;SoCal code camp&lt;/A&gt; will be held right after PDC this year. If you live in the LA area, this is a great chance to see some of the Microsoft speakers who will be presenting at PDC.&lt;/P&gt;
&lt;H3&gt;&lt;STRONG&gt;From the C# Team&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;STRONG&gt;How Do Videos on C# 4.0&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee460905.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee460905.aspx"&gt;How Do I Use Named and Optional Parameters in C# 4.0?&lt;/A&gt; (with Sam Ng) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee460939.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee460939.aspx"&gt;How Do I Use COM Interop and Office in C# 4.0?&lt;/A&gt; (with Sam Ng) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee672314.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee672314.aspx"&gt;How Do I Use Covariance and Contravariance in VS 2010 Part I?&lt;/A&gt; (with Eric Lippert) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee672319.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee672319.aspx"&gt;How Do I Use Covariance and Contravariance in VS 2010 Part II?&lt;/A&gt; (with Eric Lippert) &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;How Do Videos on the Visual Studio 2010 IDE&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee625744.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee625744.aspx"&gt;How Do I Use Highlight References in the Visual Studio 2010 IDE&lt;/A&gt; (with DJ Park) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee625748.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee625748.aspx"&gt;How Do I use Code Snippets in the Visual Studio IDE&lt;/A&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;(with Karen Liu) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee633445.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee633445.aspx"&gt;How Do I Use Generate from Usage in Visual Studio 2010?&lt;/A&gt; (with Karen Liu) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee672315.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee672315.aspx"&gt;How Do I Use the Call Hierarchy?&lt;/A&gt; (with DJ Park) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee672313.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee672313.aspx"&gt;How Do I Step with the Debugger in Visual Studio?&lt;/A&gt; (with Dustin Campbell) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee672318.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee672318.aspx"&gt;How Do I Refactor my Code in Visual Studio Part I?&lt;/A&gt; (with Dustin Campbell) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vcsharp/ee675607.aspx" mce_href="http://msdn.microsoft.com/en-us/vcsharp/ee675607.aspx"&gt;How Do I Refactor my Code in Visual Studio Part II?&lt;/A&gt; (with Dustin Campbell) &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Interview Videos on Channel 9&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;A href="http://channel9.msdn.com/posts/CharlieCalvert/CSharp-4-Dynamic-with-Chris-Burrows-and-Sam-Ng" mce_href="http://channel9.msdn.com/posts/CharlieCalvert/CSharp-4-Dynamic-with-Chris-Burrows-and-Sam-Ng"&gt;C# 4.0 Dynamic with Chris Burrows and Sam Ng&lt;/A&gt;&lt;/STRONG&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Alexandra Rusina&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/csharpfaq/archive/2009/09/14/generating-dynamic-methods-with-expression-trees-in-visual-studio-2010.aspx" mce_href="http://blogs.msdn.com/csharpfaq/archive/2009/09/14/generating-dynamic-methods-with-expression-trees-in-visual-studio-2010.aspx"&gt;Generating Dynamic Methods with Expression Trees in Visual Studio 2010&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/csharpfaq/archive/2009/10/01/dynamic-in-c-4-0-introducing-the-expandoobject.aspx" mce_href="http://blogs.msdn.com/csharpfaq/archive/2009/10/01/dynamic-in-c-4-0-introducing-the-expandoobject.aspx"&gt;Dynamic in C# 4.0: Introducing the Expando Object&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/csharpfaq/archive/2009/10/19/dynamic-in-c-4-0-creating-wrappers-with-dynamicobject.aspx" mce_href="http://blogs.msdn.com/csharpfaq/archive/2009/10/19/dynamic-in-c-4-0-creating-wrappers-with-dynamicobject.aspx"&gt;Dynamic in C# 4.0: Creating Wrappers with Dynamic Object&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Eric Lippert&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/ericlippert/archive/2009/10/19/what-is-this-thing-you-call-thread-safe.aspx" mce_href="http://blogs.msdn.com/ericlippert/archive/2009/10/19/what-is-this-thing-you-call-thread-safe.aspx"&gt;What is this thing you call "thread safe"?&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/ericlippert/archive/2009/10/15/as-timeless-as-infinity.aspx" mce_href="http://blogs.msdn.com/ericlippert/archive/2009/10/15/as-timeless-as-infinity.aspx"&gt;As Timeless As Infinity&lt;/A&gt; (On Delphi, VB Script and Exceptions) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/ericlippert/archive/2009/10/12/absence-of-evidence-is-not-evidence-of-absence.aspx" mce_href="http://blogs.msdn.com/ericlippert/archive/2009/10/12/absence-of-evidence-is-not-evidence-of-absence.aspx"&gt;Absence of evidence is not evidence of absence&lt;/A&gt; (On Constructors) &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/ericlippert/archive/2009/10/08/what-s-the-difference-between-as-and-cast-operators.aspx" mce_href="http://blogs.msdn.com/ericlippert/archive/2009/10/08/what-s-the-difference-between-as-and-cast-operators.aspx"&gt;What's the difference between "as" and "cast" operators?&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/ericlippert/archive/2009/10/05/why-no-extension-properties.aspx" mce_href="http://blogs.msdn.com/ericlippert/archive/2009/10/05/why-no-extension-properties.aspx"&gt;Why No Extension Properties?&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/ericlippert/archive/2009/10/01/why-does-char-convert-implicitly-to-ushort-but-not-vice-versa.aspx" mce_href="http://blogs.msdn.com/ericlippert/archive/2009/10/01/why-does-char-convert-implicitly-to-ushort-but-not-vice-versa.aspx"&gt;Why does char convert implicitly to ushort but not vice versa?&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Kirill Osenkov&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/kirillosenkov/archive/2009/10/19/visual-studio-2010-beta-2-known-issues.aspx" mce_href="http://blogs.msdn.com/kirillosenkov/archive/2009/10/19/visual-studio-2010-beta-2-known-issues.aspx"&gt;Visual Studio 2010 Beta 2 Known Issues&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/kirillosenkov/archive/2009/10/12/saving-images-bmp-png-etc-in-wpf-silverlight.aspx" mce_href="http://blogs.msdn.com/kirillosenkov/archive/2009/10/12/saving-images-bmp-png-etc-in-wpf-silverlight.aspx"&gt;Saving images (.bmp, .png, etc) in WPF/Silverlight&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/kirillosenkov/archive/2009/10/05/links.aspx" mce_href="http://blogs.msdn.com/kirillosenkov/archive/2009/10/05/links.aspx"&gt;Links&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Luca Bolognese&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/lucabol/archive/2009/09/22/becoming-really-rich-with-c.aspx" mce_href="http://blogs.msdn.com/lucabol/archive/2009/09/22/becoming-really-rich-with-c.aspx"&gt;Becoming really rich with C#&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;Beta 2&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Visual Studio 2010 &lt;A href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=csharpfuture&amp;amp;DownloadId=7632" mce_href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=csharpfuture&amp;amp;DownloadId=7632"&gt;Samples&lt;/A&gt;&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;A href="http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx?pv=18:370" mce_href="http://msdn.microsoft.com/en-us/subscriptions/downloads/default.aspx?pv=18:370"&gt;MSDN Subscribers: Download the Beta&lt;/A&gt;&lt;/STRONG&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://channel9.msdn.com/shows/10-4/10-4-Episode-33-Downloading-and-Installing-Visual-Studio-2010-Beta-2/" mce_href="http://channel9.msdn.com/shows/10-4/10-4-Episode-33-Downloading-and-Installing-Visual-Studio-2010-Beta-2/"&gt;A Video on How to Download and Install the Beta&lt;/A&gt; &lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx" mce_href="http://msdn.microsoft.com/en-us/vstudio/dd441784.aspx"&gt;Walkthroughs and Related Content&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;&lt;STRONG&gt;From the C# Community at Microsoft&lt;/STRONG&gt;&lt;/H3&gt;
&lt;P&gt;&lt;STRONG&gt;Scott Guthrie&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/scottgu/archive/2009/10/15/announcing-microsoft-ajax-library-preview-6-and-the-microsoft-ajax-minifier.aspx" mce_href="http://weblogs.asp.net/scottgu/archive/2009/10/15/announcing-microsoft-ajax-library-preview-6-and-the-microsoft-ajax-minifier.aspx"&gt;Announcing Microsoft Ajax Library (Preview 6) and the Microsoft Ajax Minifier&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx" mce_href="http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx"&gt;URL Routing with ASP.NET 4 Web Forms (VS 2010 and .NET 4.0 Series)&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Scott Hanselman&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://feedproxy.google.com/~r/ScottHanselman/~3/nlo-NV9tMms/VisualStudio2010Beta2.aspx" mce_href="http://feedproxy.google.com/~r/ScottHanselman/~3/nlo-NV9tMms/VisualStudio2010Beta2.aspx"&gt;Visual Studio 2010 Beta 2&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://feedproxy.google.com/~r/ScottHanselman/~3/VWXarnbHm8E/HanselminutesOnChannel9InsideCodePlexcom.aspx" mce_href="http://feedproxy.google.com/~r/ScottHanselman/~3/VWXarnbHm8E/HanselminutesOnChannel9InsideCodePlexcom.aspx"&gt;Hanselminutes on Channel 9 - Inside CodePlex.com&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://feedproxy.google.com/~r/ScottHanselman/~3/3oOFaBsv9eg/HanselminutesPodcast184PreviewOfASPNET4WithScottHunter.aspx" mce_href="http://feedproxy.google.com/~r/ScottHanselman/~3/3oOFaBsv9eg/HanselminutesPodcast184PreviewOfASPNET4WithScottHunter.aspx"&gt;Hanselminutes Podcast 184: Preview of ASP.NET 4 with Scott Hunter&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://feedproxy.google.com/~r/ScottHanselman/~3/r8Y5FyI_Jbw/ObscureWindowsHomeServerTipRestoringWhenYouDidntHaveNetworkDriversInstalledBefore.aspx" mce_href="http://feedproxy.google.com/~r/ScottHanselman/~3/r8Y5FyI_Jbw/ObscureWindowsHomeServerTipRestoringWhenYouDidntHaveNetworkDriversInstalledBefore.aspx"&gt;Windows Home Server: Restoring when you didn't have Network Drivers installed before&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://feedproxy.google.com/~r/ScottHanselman/~3/sBkZg5Ryl9g/HanselminutesPodcast183LIVEGadgetsHiDefWebCams4GAndMore.aspx" mce_href="http://feedproxy.google.com/~r/ScottHanselman/~3/sBkZg5Ryl9g/HanselminutesPodcast183LIVEGadgetsHiDefWebCams4GAndMore.aspx"&gt;Hanselminutes Podcast 183: LIVE! Gadgets, Hi-Def, WebCams, 4G and More&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://feedproxy.google.com/~r/ScottHanselman/~3/VwBZxqTbJX0/ANewMSDNForANewOperatingSystemAndANewDevelopmentEnvironment.aspx" mce_href="http://feedproxy.google.com/~r/ScottHanselman/~3/VwBZxqTbJX0/ANewMSDNForANewOperatingSystemAndANewDevelopmentEnvironment.aspx"&gt;A new MSDN for a new Operating System and a new Development Environment&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://feedproxy.google.com/~r/ScottHanselman/~3/Bha0h4oOUO0/ReviewAndComparisonMicrosoftLifeCamCinemaHDAndVX7000WithHighQualityVideoInSkypeAndLiveMessenger.aspx" mce_href="http://feedproxy.google.com/~r/ScottHanselman/~3/Bha0h4oOUO0/ReviewAndComparisonMicrosoftLifeCamCinemaHDAndVX7000WithHighQualityVideoInSkypeAndLiveMessenger.aspx"&gt;Review and Comparison: Microsoft LifeCam Cinema HD and VX-7000 with High Quality Video in Skype and Live Messenger&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Dan Fernandez&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title=article-5902171-146 name=article-5902171-146&gt;&lt;/A&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;H5&gt;&lt;A href="http://blogs.msdn.com/danielfe/archive/2009/10/13/my-pics-for-pdc-2009.aspx" mce_href="http://blogs.msdn.com/danielfe/archive/2009/10/13/my-pics-for-pdc-2009.aspx"&gt;My Picks for PDC 2009&lt;/A&gt;&lt;/H5&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;H5&gt;&lt;A href="http://channel9.msdn.com/shows/Coding4FunTV/The-Coding4Fun-Show-Advanced-Rendering-with-Silverlight-Rick-Barraza/" mce_href="http://channel9.msdn.com/shows/Coding4FunTV/The-Coding4Fun-Show-Advanced-Rendering-with-Silverlight-Rick-Barraza/"&gt;The Coding4Fun Show: Advanced Rendering with Silverlight, Rick Barraza&lt;/A&gt; &lt;/H5&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;MSDN Magazine&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/msdnmagazine/archive/2009/10/09/9905842.aspx" mce_href="http://blogs.msdn.com/msdnmagazine/archive/2009/10/09/9905842.aspx"&gt;Lining Up Columns&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/msdnmagazine/archive/2009/10/08/9905656.aspx" mce_href="http://blogs.msdn.com/msdnmagazine/archive/2009/10/08/9905656.aspx"&gt;A Necessary 101 on Professional Application Development&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/msdnmagazine/archive/2009/10/07/9904758.aspx" mce_href="http://blogs.msdn.com/msdnmagazine/archive/2009/10/07/9904758.aspx"&gt;File &amp;gt; New &amp;gt; Project: Developing a New MSDN Magazine!!&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Mitsu&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://blogs.msdn.com/mitsu/archive/2009/09/08/surface-academy-toolkit-2009.aspx" mce_href="http://blogs.msdn.com/mitsu/archive/2009/09/08/surface-academy-toolkit-2009.aspx"&gt;Surface Academy Toolkit with Card Game, plus Dick Lantim!&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;H3&gt;From the Community&lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.ineta.org/newsletters/2009_09.htm" mce_href="http://www.ineta.org/newsletters/2009_09.htm"&gt;September INETA Newsletter&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;A href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f19%2fcommunity-convergence-lvi.aspx" mce_href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f19%2fcommunity-convergence-lvi.aspx"&gt;&lt;IMG border=0 alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f19%2fcommunity-convergence-lvi.aspx" mce_src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f10%2f19%2fcommunity-convergence-lvi.aspx"&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9890489" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Community Convergence" scheme="http://blogs.msdn.com/charlie/archive/tags/Community+Convergence/default.aspx" /><category term="Video" scheme="http://blogs.msdn.com/charlie/archive/tags/Video/default.aspx" /><category term="C# 4.0" scheme="http://blogs.msdn.com/charlie/archive/tags/C_2300_+4.0/default.aspx" /></entry><entry><title>The XNA Role Playing Game Starter Kit</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/09/27/xna-role-playing-game.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/09/27/xna-role-playing-game.aspx</id><published>2009-09-27T20:18:06Z</published><updated>2009-09-27T20:18:06Z</updated><content type="html">&lt;p&gt;In my spare time I’ve been looking at the C#code for the &lt;a href="http://creators.xna.com/en-US/starterkit/roleplayinggame"&gt;XNA Role Playing Game starter kit&lt;/a&gt;. This kit is not new, but I’m interested in Role Playing Games (RPGs), so I thought I’d keep some notes on what I’m learning as I play with it. Though not especially fancy, I like this code as it represents something that a developer with intermediate level skills can pick up without too much effort. It would be fun to write the next Fallout or WarCraft during my spare time on the weekend, but since my resources and patience are limited I thought it might be more rewarding to work on a simpler project.&lt;/p&gt;  &lt;p&gt;The starter kit comes as an MSI installable package. It adds a new template into Visual Studio, making it possible for you to choose &lt;strong&gt;File | New | Role Playing Game&lt;/strong&gt; from the menu. This one step process initiates the creation of a new solution containing the source for a complete tile-based role playing game. In Figure 1 you can see the Solution Explorer and Class View for the created project. By viewing this screen shot you can get some sense of what is available inside the start kit. Obviously this is a fairly extensive bit of source code with lots of logic for you to digest and learn from, especially if you are new to game development.&lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure01-SolutionExplorer_&amp;amp;_ClassView" border="0" alt="Figure01-SolutionExplorer_&amp;amp;_ClassView" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/XNARolePlayingGame_7F56/Figure01-SolutionExplorer_&amp;amp;_ClassView_3.png" width="599" height="481" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 1: Class View and the Solution Explore for the XNA Role Playing Starter Kit.&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;The Tile Engine&lt;/h2&gt;  &lt;p&gt;The kit features a simple tile engine written in C# which supports several layers. The first layer allows you to define a basic landscape or the interior of a building. A second layer allows you to decorate it with trees, chairs, or other objects. A third layer contains your sprites, and a fourth layer defines the boundaries inside which the sprites can move.&lt;/p&gt;  &lt;p&gt;As is usually the case with tile engines, this code base allows you to work with a series of two dimensional numerical arrays, each of which contain simple integers defining offsets into a set of tiled bit maps. For instance, if you stare hard enough at Figure 2, you can see that it can be broken out into six separate “tiles”, three on the top, and three on the bottom, where the middle tile on the bottom row looks a bit like grass. &lt;/p&gt;  &lt;p&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure02-Tiles" border="0" alt="Figure02-Tiles" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/XNARolePlayingGame_7F56/Figure02-Tiles_3.png" width="200" height="133" /&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 2: A tiny excerpt from the tile map used in the starter kit.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you mentally assigned numbers to the tiles in the bitmap then you could use these digits as names for each of the six tiles in this source bitmap. The numbers 1, 2 and 3 would range across the top row, and 4, 5 and 6 across the bottom row. You can now create a two dimensional array like this which would represents offsets into the tiles:&lt;/p&gt;  &lt;p&gt;4 5 5 6&lt;/p&gt;  &lt;p&gt;4 5 5 6&lt;/p&gt;  &lt;p&gt;The tile engine then reads the array, calculates the offsets into the source bitmap, and blits out the tiles designated into a final map, as shown in Figure 3. Here you see the two outermost tiles on the bottom row of the source bitmap, plus the center tile on the bottom row repeated twice. None of the tiles on the top row of the source tile map are used in this example.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/XNARolePlayingGame_7F56/Figure03-Map_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure03-Map" border="0" alt="Figure03-Map" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/XNARolePlayingGame_7F56/Figure03-Map_thumb.png" width="244" height="107" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 3: A small world map created from calculating offsets into the tiles seen in the second row of Figure 2.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you have a larger source and destination tile map, a larger array, and a larger world map with multiple layers, then you can create entire landscapes inhabited by characters, such as the one shown in Figure 4. This screen shot is taken from the world map used in the starter kit. The water and land are defined by the bottom array in the tile engine, the trees are defined in the second layer, and the two characters are defined in the third layer. The fourth layer is used to ensure that characters are not able to walk out onto the water. In short, the fourth layer defines boundaries for the movement of sprites in the game.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/XNARolePlayingGame_7F56/Figure04-WorldMap_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Figure04-WorldMap" border="0" alt="Figure04-WorldMap" src="http://blogs.msdn.com/blogfiles/charlie/WindowsLiveWriter/XNARolePlayingGame_7F56/Figure04-WorldMap_thumb.png" width="644" height="378" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Figure 4: The playing screen from the starter kit. Click the screen shot to see a full size image.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Of course, this is a two dimensional tile map, and not a 3D engine. If you want a 3D engine, XNA can support one, and there are &lt;a href="http://creators.xna.com/en-US/starterkit/racinggame"&gt;starter kits&lt;/a&gt; and many &lt;a href="http://www.codeplex.com/site/search?projectSearchText=XNA%203D"&gt;game engines&lt;/a&gt; that can help you get started. However, if you just want to hack around a bit without burning up the midnight oil, your career, your marriage, and the best years of your life, a 2D engine is both convenient and practical.&lt;/p&gt;  &lt;p&gt;The tile engine and other tools from the starter kit are reasonably well designed and fairly modular. If you develop an urge to do so, you should have little trouble stripping them out of this game and putting them to use in your own custom projects. Additionally, they provide examples of best practices, so studying them may be a productive exercise. You might find this true even if you want to create a very different game driven by a 3D engine.&lt;/p&gt;  &lt;p&gt;Questions about licensing issues should be addressed to &lt;a href="http://forums.xna.com/forums/t/11880.aspx"&gt;the XNA team&lt;/a&gt;, but I’ll express some muted optimism here because the starter kit is released under &lt;a href="http://creators.xna.com/downloads/?id=15"&gt;the MSPL&lt;/a&gt;, and because the team explains at some length how to use the code in your own projects. In particular, the XNA team provides additional information about &lt;a href="http://creators.xna.com/en-US/tutorial/roleplayinggametutorial2"&gt;reusing the tile engine&lt;/a&gt; in your own game. I suggest you read through all the text on the tile engine, as it provides useful information about the structure of the RPG Starter Kit.&lt;/p&gt;  &lt;h2&gt;The Quest Engine&lt;/h2&gt;  &lt;p&gt;Another important feature of the game is the quest engine. role playing games generally feature a series of tasks that the player is expected to complete. For instance, in many RPGs one might have to crawl through a dungeon and find a jewel, or go to war against a series of trolls that have taken over a house. When you have completed the task, you generally report back to some non-playing character (NPC) who gives you a reward for completing the job. When you have finished all the tasks supplied with the game, then a screen comes up with lots of flashing graphics, and you are told that you have won. Why I find it enjoyable to do this I have no idea, but my experience is that many people, including myself, are drawn to this kind of experience. &lt;/p&gt;  &lt;p&gt;The XNA RPG Starter Kit comes with C# code demonstrating how to construct a quest engine. The engine is driven by a series of XML files. By manipulating the text in these files you can modify existing quests and add new quests. This means that there is a rough separation of the data, which is stored in the XML files, and the actions, which are written in C#. At least in theory, you need never change the C# code, all you need do is modify the XML. This kind of design is a best practice, and one that developers can learn from – if you haven’t already implemented a similar scheme in your own code. (Note that the two dimensional arrays defined in the tile engine provide a similar functionality for that code base. Clearly the developers of this starter kit believe in separating data and code.)&lt;/p&gt;  &lt;p&gt;Here is &lt;a href="http://creators.xna.com/en-US/tutorial/roleplayinggametutorial1"&gt;information&lt;/a&gt; on how to use the quest engine. It is a simple tutorial you can complete in about 20 or 30 minutes. In it you learn how to modify quests, and how to create your own quests.&lt;/p&gt;  &lt;h2&gt;Acquiring the Starting Kit&lt;/h2&gt;  &lt;p&gt;The downloads for the &lt;a href="http://creators.xna.com/en-US/starterkit/roleplayinggame"&gt;RGP Starter Kit&lt;/a&gt; are broken out into versions for XNA Game Studio 2.0 and 3.0. There is also a distinction between code that targets Windows and code for the XBox:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://creators.xna.com/downloads/?id=220"&gt;For XNA Game Studio 3.0 Windows&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://creators.xna.com/downloads/?id=221"&gt;For XNA Game Studio 3.0 XBox 360&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://creators.xna.com/downloads/?id=83"&gt;For XNA Game Studio 2.0 Windows&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://creators.xna.com/downloads/?id=84"&gt;For XNA Game Studio 2.0 XBox 360&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here are some additional links&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://creators.xna.com/en-US/starterkit/roleplayinggame"&gt;Home page and some documentation&lt;/a&gt; for the starter kit. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://forums.xna.com/forums/t/11880.aspx"&gt;Forum thread for discussing the kit&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;Information on the &lt;a href="http://creators.xna.com/en-US/tutorial/roleplayinggametutorial1"&gt;quest engine&lt;/a&gt;. &lt;/li&gt;    &lt;li&gt;Information the the &lt;a href="http://creators.xna.com/en-US/tutorial/roleplayinggametutorial2"&gt;tile engine&lt;/a&gt;. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here is the documentation for the &lt;a href="http://msdn.microsoft.com/en-us/library/bb943865(VS.85).aspx"&gt;Microsoft Cross Platform Audio Creation Tool (XACT)&lt;/a&gt;. I’ll try to find time to describe it in a future article, as the music included with this game should come with warnings about its potential affect on your mental health. It turns out to be very easy to take MP3s of your favorite music and add them to the game so that you can tinker in peace.&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h2&gt;Summary&lt;/h2&gt;  &lt;p&gt;The rains will be settling in here in Redmond in just a few more weeks. As we contemplate the coming of winter, its nice to prepare a little something to do to wile away a peaceful, but wet, Saturday afternoon. Tinkering with the source for a game is one rewarding option. In this post I’ve accomplished almost nothing that I set out to do, but I have managed to introduce the XNA RPG Starter kit. Hopefully I can find time to come back and explore some of the modifications I’ve been making to the kit, and to explain a little about how it works and what useful lessons we might learn from it.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f09%2f27%2fxna-role-playing-game.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f09%2f27%2fxna-role-playing-game.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9900024" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Games" scheme="http://blogs.msdn.com/charlie/archive/tags/Games/default.aspx" /></entry><entry><title>.NET University is Live</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/charlie/archive/2009/09/21/net-university-is-live.aspx" /><id>http://blogs.msdn.com/charlie/archive/2009/09/21/net-university-is-live.aspx</id><published>2009-09-22T00:05:20Z</published><updated>2009-09-22T00:05:20Z</updated><content type="html">&lt;p&gt;Doug Turnure and Mark Dunn just reopened the &lt;a title="Dot Net University" href="http://www.dotnet-u.com"&gt;.NET University&lt;/a&gt; site.&amp;#160; This resource includes approximately 40 developer-oriented presentation kits that include slides, speaker notes, demos, demo scripts and webcast videos. You can use these materials in your own presentations, or simply access the valuable information that they contain. You can also find free, sequenced online training at &lt;a href="http://myrampup.com"&gt;http://myrampup.com&lt;/a&gt;. Ramp Up is a free, online, community-based learning program, with a number of different tracks that will help you build your portfolio of professional development skills.&lt;/p&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f09%2f21%2fnet-university-is-live.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblogs.msdn.com%2fcharlie%2farchive%2f2009%2f09%2f21%2fnet-university-is-live.aspx" /&gt;&lt;/a&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9897747" width="1" height="1"&gt;</content><author><name>ccalvert</name><uri>http://blogs.msdn.com/members/ccalvert.aspx</uri></author><category term="CSharp" scheme="http://blogs.msdn.com/charlie/archive/tags/CSharp/default.aspx" /><category term="Community" scheme="http://blogs.msdn.com/charlie/archive/tags/Community/default.aspx" /></entry></feed>