<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results for 'app:weblogs' matching tag 'VB'</title><link>http://msmvps.com/search/SearchResults.aspx?q=app:weblogs&amp;tag=VB&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tag 'VB'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Workflow 4 and Visual Basic expressions</title><link>http://msmvps.com/blogs/theproblemsolver/archive/2009/10/26/workflow-4-and-visual-basic-expressions.aspx</link><pubDate>Mon, 26 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1735366</guid><dc:creator>Maurice</dc:creator><description>&lt;p&gt;When using Windows Workflow Foundation 4 you often need to enter expression in some activity property. The new thing is these expressions are all in the Visual Basic dialect regardless of what language you project is in. So when developing a project in C# the expressions are sill in Visual Basic.&lt;/p&gt;  &lt;p&gt;Weird right?&lt;/p&gt;  &lt;p&gt;Well not really when you think about it!&lt;/p&gt;  &lt;p&gt;After all power business users are expected to be able to modify workflows. And guess what their favorite tools are. That would be Microsoft Excel and Word. And what do they use to create macros? Right Visual Basic for Applications is their language of choice.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So if they use VBA letting them enter VB into expression dialogs is a far more natural fit than having them use C#.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;A case for the Delay activity&lt;/h3&gt;  &lt;p&gt;So lets take a look at the delay activity. This activity takes 1 input property Duration of type Time Span. So I guess that means our VBA power users are going to have to enter something like if they want to wait 5 seconds:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/theproblemsolver.metablogapi/3175.image_5F00_51844A7D.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/theproblemsolver.metablogapi/4670.image_5F00_thumb_5F00_10099824.png" width="346" height="201" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now for some reason I suspect that is not the first thing they are going to type. In fact they are more likely to time something like “0:0:05” instead. Not very VB like right?&lt;/p&gt;  &lt;p&gt;Well it turns out workflow is smart enough to realize it can convert the string literal to a Time Span and use this. So when our power users does the following it just works &lt;img src="http://msmvps.com/emoticons/emotion-1.gif" alt="Smile" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/theproblemsolver.metablogapi/2514.image_5F00_75C92EFF.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;border-top:0px;border-right:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/theproblemsolver.metablogapi/3187.image_5F00_thumb_5F00_5F9313AD.png" width="344" height="202" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Nice, I like this!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Enjoy WF4!&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.theproblemsolver.nl/"&gt;www.TheProblemSolver.nl &lt;/a&gt;   &lt;br /&gt;&lt;a href="http://wiki.windowsworkflowfoundation.eu/"&gt;Wiki.WindowsWorkflowFoundation.eu&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Unit Testing: Execution</title><link>http://msmvps.com/blogs/deborahk/archive/2009/10/25/unit-testing-execution.aspx</link><pubDate>Sun, 25 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1735158</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;Visual Studio 2008 (Professional Edition and above) provides a really nice set of tools for development and execution of unit tests.&lt;/p&gt;  &lt;p&gt;[To begin with an overview of unit testing, &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/10/25/unit-testing-an-introduction.aspx"&gt;start here&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/10/25/unit-testing-an-introduction.aspx"&gt;This prior post&lt;/a&gt; demonstrates how to build a unit test using the &amp;quot;Create Unit Tests...&amp;quot; feature of the Code Editor. This post demonstrates how to execute a unit test.&lt;/p&gt;  &lt;p&gt;NOTE: This post assumes you have already generated or created at least one unit test.&lt;/p&gt;  &lt;p&gt;To execute one or more unit tests:&lt;/p&gt;  &lt;p&gt;1) Open your solution in Visual Studio.&lt;/p&gt;  &lt;p&gt;The solution should include both the project(s) to test and the test project(s).&lt;/p&gt;  &lt;p&gt;2) Select Test | Windows | Test View from the menu to view the Test View window. This window contains every method marked with the TestMethod attribute.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2620.image_5F00_27D6A4F6.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6518.image_5F00_thumb_5F00_40561C79.png" width="457" height="247" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The solution used for the screenshot above has two LastNameTest unit tests: One for the VB example and one for the C# example. If you coded along&amp;#160; from the prior unit testing post, you will only have one for whichever language you selected. If you have been creating unit tests for one of your projects, you may have hundreds of tests in this list.&lt;/p&gt;  &lt;p&gt;To execute unit tests:&lt;/p&gt;  &lt;p&gt;1) Select one or&amp;#160; more tests from the list of tests in the Test View window.&lt;/p&gt;  &lt;p&gt;You can add columns and sort the list or use the filter feature to make it easier to locate and select the desired tests to execute.&lt;/p&gt;  &lt;p&gt;2) Click the Run Selection button in the upper left&amp;#160; corner of the Test View window or right-click on any selected test and select &amp;quot;Run Selection&amp;quot; from the context menu.&lt;/p&gt;  &lt;p&gt;The selected test(s) will then execute, displaying their status in the Test Results window:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6180.image_5F00_543F8942.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4428.image_5F00_thumb_5F00_0A145890.png" width="505" height="142" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;When the test is complete, the Test Results window will look something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2055.image_5F00_1967BA9F.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0777.image_5F00_thumb_5F00_75EB1639.png" width="499" height="128" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Both of&amp;#160; the tests shown in the above screenshot are marked as Inconclusive because the generated unit testing code used the Assert class Inconclusive method. The generated unit testing template is designed to prevent a false positive. It generates an inconclusive result until you update the unit test with correct valid and invalid values and remove the Inconclusive method call.&lt;/p&gt;  &lt;p&gt;To see more information on the result of the test, double-click on a test result.&lt;/p&gt;  &lt;p&gt;To run the test again, use the Run or Debug buttons at the top of the Test Results window.&lt;/p&gt;  &lt;p&gt;If any of&amp;#160; the tests don&amp;#39;t pass, they are marked as Failed in the Test Results window as shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2475.image_5F00_57047C8E.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5684.image_5F00_thumb_5F00_6A719095.png" width="499" height="138" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Double click on any of&amp;#160; the failed tests to view the test results:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/1033.image_5F00_085F78BD.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/2502.image_5F00_thumb_5F00_1A9819B2.png" width="475" height="389" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The Error Stack Trace at the bottom of this window gives you further information on the source of the failure. Click on any link in the stack trace to jump to the associated location in the code.&lt;/p&gt;  &lt;p&gt;You can also debug the code as the test is executing if you &amp;quot;Debug Selection&amp;quot; option instead of the &amp;quot;Run Selection&amp;quot; option.&lt;/p&gt;  &lt;p&gt;After you update the unit tests with valid code and the tests pass, the Test Results will appear as follows:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/3755.image_5F00_617116E2.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6215.image_5F00_thumb_5F00_11B7EB99.png" width="473" height="131" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice the color-coded green passing indicator.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Unit Testing: An Introduction</title><link>http://msmvps.com/blogs/deborahk/archive/2009/10/25/unit-testing-an-introduction.aspx</link><pubDate>Sun, 25 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1735139</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;If you have Visual Studio 2008 or later and have the Professional Edition or better (NOT the Express Editions), you have some very nice unit testing tools within your Visual Studio environment. These tools help you write, execute, and track your unit tests and code coverage. This post provides an introduction to using these tools.&lt;/p&gt;  &lt;p&gt;If you are new to unit testing, the idea is to test the smallest possible units of your code. In most cases, the smallest units of code are the property procedures and methods of your classes.&lt;/p&gt;  &lt;p&gt;For more general information about the purpose of unit testing, see &lt;a href="http://en.wikipedia.org/wiki/Unit_testing"&gt;this link&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;NOTE: Unit testing is not meant to replace integration testing, system testing, or user testing.&lt;/p&gt;  &lt;p&gt;In some development methodologies, such as Test Driven Development (TDD), unit tests are written &lt;em&gt;before&lt;/em&gt; the code is written. You capture the basic requirements in the unit test and then write the code. The code is complete when the unit tests&amp;#160; pass. Visual Studio 2010 has features to assist with this &amp;quot;unit test first&amp;quot; approach.&lt;/p&gt;  &lt;p&gt;But&amp;#160; this introduction demonstrates how to write unit tests for &lt;em&gt;existing&lt;/em&gt; code. This technique is helpful if you follow a code-first approach or if you received code from another source or have old code that did not originally have unit tests.&lt;/p&gt;  &lt;h2&gt;Build the Code&lt;/h2&gt;  &lt;p&gt;The business object tested in this post is a simplified Customer class that uses the business object base class defined in &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/07/21/building-a-business-object-base-class.aspx"&gt;this post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The Customer class is shown below.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;public class Customer: BoBase      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; private int? _CustomerId;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public int? CustomerId       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return _CustomerId; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; internal set       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (_CustomerId == null || !_CustomerId.Equals(value))       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&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; string propertyName = &amp;quot;CustomerId&amp;quot;;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;// Perform any validation here      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&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; if (!_CustomerId.Equals(value))      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _CustomerId = value;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetEntityState(EntityStateType.Modified,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; propertyName);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; private string _LastName;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string LastName       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return _LastName; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (_LastName == null || _LastName != value)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&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; string propertyName = &amp;quot;LastName&amp;quot;;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&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; // Perform any validation here&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&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; if (_LastName != value)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _LastName = value;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetEntityState(EntityStateType.Modified,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; propertyName);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; private string _FirstName;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string FirstName       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return _FirstName; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (_FirstName == null || _FirstName != value)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&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; string propertyName = &amp;quot;FirstName&amp;quot;;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&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; // Perform any validation here&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&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; if (_FirstName != value)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _FirstName = value;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetEntityState(EntityStateType.Modified,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; propertyName);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; private string _EmailAddress;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; public string EmailAddress       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get { return _EmailAddress; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (_EmailAddress == null || _EmailAddress != value)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&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; string propertyName = &amp;quot;EmailAddress&amp;quot;;&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&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; // Perform any validation here&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&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; if (_EmailAddress != value)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _EmailAddress = value;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetEntityState(EntityStateType.Modified,       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; propertyName);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Public Class Customer      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Inherits BOBase &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; Private _CustomerId As Integer?      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property CustomerId() As Integer?       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return _CustomerId       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Friend Set(ByVal value As Integer?)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;If _CustomerId Is Nothing OrElse _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Not _CustomerId.Equals(value) Then       &lt;br /&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; Dim propertyName As String = &amp;quot;CustomerId&amp;quot;       &lt;br /&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;#39; Perform any validation&amp;#160; &lt;br /&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; If Not _CustomerId.Equals(value) Then       &lt;br /&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; _CustomerId = value       &lt;br /&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; SetEntityState(EntityStateType.Modified, propertyName)       &lt;br /&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; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If       &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Set      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Property &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; Private _FirstName As String      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property FirstName() As String       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return _FirstName       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Set(ByVal value As String)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; If _FirstName Is Nothing OrElse _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _FirstName IsNot value Then       &lt;br /&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; Dim propertyName As String = &amp;quot;FirstName&amp;quot;       &lt;br /&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;#39; Perform any validation       &lt;br /&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; If _FirstName IsNot value Then       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _FirstName = value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetEntityState(EntityStateType.Modified, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&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; propertyName)       &lt;br /&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; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Set       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Property &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; Private _LastName As String      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property LastName() As String       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return _LastName       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Set(ByVal value As String)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; If _LastName Is Nothing OrElse _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _LastName IsNot value Then       &lt;br /&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; Dim propertyName As String = &amp;quot;LastName&amp;quot;       &lt;br /&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;#39; Perform any validation       &lt;br /&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; If _LastName IsNot value Then       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _LastName = value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetEntityState(EntityStateType.Modified, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&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; propertyName)       &lt;br /&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; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Set       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Property &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160; Private _EmailAddress As String      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Public Property EmailAddress() As String       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Return _EmailAddress       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Get       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Set(ByVal value As String)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; If _EmailAddress Is Nothing OrElse _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _EmailAddress IsNot value Then       &lt;br /&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; Dim propertyName As String = &amp;quot;EmailAddress&amp;quot;       &lt;br /&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;#39; Perform any validation       &lt;br /&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; If _EmailAddress IsNot value Then       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _EmailAddress = value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; SetEntityState(EntityStateType.Modified, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&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; propertyName)       &lt;br /&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; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End If       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; End Set       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; End Property       &lt;br /&gt;End Class&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The first if statement in each of the property procedures for the Customer class checks whether the current value is null or was changed. If the property is changed, you want to revalidate it, set it as modified, and generate a PropertyChanged event (which is handled in the SetEntityState method).&lt;/p&gt;  &lt;p&gt;NOTE: C# uses a != operator to judge whether the value was changed. VB cannot use the &amp;lt;&amp;gt; operator because VB propagates null values. So if either value is null (nothing) the result is false. (See &lt;a href="http://msdn.microsoft.com/en-us/library/0x9tb07z.aspx"&gt;this msdn entry&lt;/a&gt; for more information.) To prevent this problem, IsNot is used in the VB code to determine if the value was changed.&lt;/p&gt;  &lt;p&gt;The null check allows for possible validation of required fields (that is, fields that cannot be null or empty). If you know you will never need a null validation check, you can leave the null check off the first if statement.&lt;/p&gt;  &lt;p&gt;The propertyName variable defines a name&amp;#160; that you can use in any validation error messages and it is the name used in the PropertyChanged event.&lt;/p&gt;  &lt;p&gt;You can then perform any necessary validation. In this simple example, no validation was added. If you want to see an example of some validation, check out &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/07/21/building-a-business-object-base-class.aspx"&gt;this post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Finally, if the value was changed, the backing variable is set to the new value and the SetEntityState method is called&amp;#160; to mark the business object as&amp;#160; &amp;quot;dirty&amp;quot; and to generate the PropertyChanged event.&lt;/p&gt;  &lt;h2&gt;Define the Testing Scenarios&lt;/h2&gt;  &lt;p&gt;So let&amp;#39;s start with the test of the LastName property. Looking at the requirements, the following testing scenarios are required:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Initial null value; set to null value (should perform validation but not set the dirty flag) &lt;/li&gt;    &lt;li&gt;Initial null value; set to valid&amp;#160; string (should perform validation and set the dirty flag) &lt;/li&gt;    &lt;li&gt;Initial null value; set to empty string (should perform validation and set the dirty flag) &lt;/li&gt;    &lt;li&gt;Initial string value; set to null value (should perform validation and set the dirty flag) &lt;/li&gt;    &lt;li&gt;Initial string value, set to different string value (should perform validation and set the dirty flag) &lt;/li&gt;    &lt;li&gt;Initial string value, set&amp;#160; to same string value (should not&amp;#160; perform validation and not set the dirty flag) &lt;/li&gt;    &lt;li&gt;Initial string value, set&amp;#160; to empty value (should perform validation and set the dirty flag) &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;And if you have validation code, you will have more scenarios to test valid and invalid values. But this is enough to give you the general idea.&lt;/p&gt;  &lt;p&gt;So now let&amp;#39;s generate the unit test for the LastName property using the tools provided in Visual Studio (Professional Edition or above).&lt;/p&gt;  &lt;h2&gt;Generate the Unit Test&lt;/h2&gt;  &lt;p&gt;The following are the steps for generating the unit test for a particular property procedure or method:&lt;/p&gt;  &lt;p&gt;1) Open the Code Editor for the code you want to test.&lt;/p&gt;  &lt;p&gt;2) Right-click and select Create Unit Tests... from the context menu.&lt;/p&gt;  &lt;p&gt;The following dialog will appear:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/7713.image_5F00_52563B2F.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6646.image_5F00_thumb_5F00_77DFB890.png" width="430" height="318" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3) Select the properties, methods, or&amp;#160; constructors you wish to test.&lt;/p&gt;  &lt;p&gt;If you were in a specific property procedure or method, that procedure or method is automatically checked in this dialog. You can select to generate tests for any properties, methods,&amp;#160; or constructors using this dialog.&lt;/p&gt;  &lt;p&gt;Notice the Output project combobox on this dialog. Using this combobox, you can create a new C# unit test, new VB unit test, or select any existing unit test project if you already&amp;#160; have some in your solution. This allows you to add unit tests to existing unit testing projects at any point in the development process.&lt;/p&gt;  &lt;p&gt;4) Click OK.&lt;/p&gt;  &lt;p&gt;5) If you are creating a new C# or VB project, enter the project name and click Create.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0385.image_5F00_4F60D67C.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/4274.image_5F00_thumb_5F00_2E6D63D5.png" width="416" height="136" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;6) The test project is then added to your Solution Explorer.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5734.image_5F00_0D79F12E.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6327.image_5F00_thumb_5F00_3E992BCE.png" width="408" height="327" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you created a VB test project, the result is the same, but with a CustomerTest.vb file&amp;#160; within the BoTest project.&lt;/p&gt;  &lt;h2&gt;View the Generated Code&lt;/h2&gt;  &lt;p&gt;Visual Studio automatically creates an first cut of your unit testing code.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Double-click on&amp;#160; CustomerTest.cs to view the code.&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;/// &amp;lt;summary&amp;gt;      &lt;br /&gt;///A test for LastName       &lt;br /&gt;///&amp;lt;/summary&amp;gt;       &lt;br /&gt;[TestMethod()]       &lt;br /&gt;public void LastNameTest()       &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Customer target = new Customer(); // TODO: Initialize to an appropriate value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string expected = string.Empty; // TODO: Initialize to an appropriate value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; string actual;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; target.LastName = expected;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; actual = target.LastName;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.AreEqual(expected, actual);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.Inconclusive(&amp;quot;Verify the correctness of this test method.&amp;quot;);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Double-click on CustomerTest.vb to view the code.&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#39;&amp;#39;&amp;#39;&amp;lt;summary&amp;gt;      &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39;A test for LastName       &lt;br /&gt;&amp;#39;&amp;#39;&amp;#39;&amp;lt;/summary&amp;gt;       &lt;br /&gt;&amp;lt;TestMethod()&amp;gt; _       &lt;br /&gt;Public Sub LastNameTest()       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim target As Customer = New Customer &amp;#39; TODO: Initialize to an appropriate value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim expected As String = String.Empty &amp;#39; TODO: Initialize to an appropriate value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Dim actual As String       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; target.LastName = expected       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; actual = target.LastName       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.AreEqual(expected, actual)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Assert.Inconclusive(&amp;quot;Verify the correctness of this test method.&amp;quot;)       &lt;br /&gt;End Sub&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;The TestMethod attribute defines this method as a unit test. It is then picked up by the other unit testing tools within Visual Studio.&lt;/p&gt;  &lt;p&gt;The generated code includes some ToDo notes, defining where you should change the code.&lt;/p&gt;  &lt;p&gt;The Assert class is a key aspect of your unit tests. It provides many methods that you can use to assert whether your test produced expected results.&lt;/p&gt;  &lt;p&gt;The generated code uses two of the Assert class methods. The &lt;strong&gt;AreEqual&lt;/strong&gt; method determines whether the expected and actual values are equal. If not, it fails the test.&lt;/p&gt;  &lt;p&gt;The &lt;strong&gt;Inconclusive&lt;/strong&gt; method always causes the test to fail. This is added to all generated code to ensure that the test will fail until you modify the test with valid values.&lt;/p&gt;  &lt;p&gt;At this point, you can try to execute this unit test, or update it first and then execute it.&lt;/p&gt;  &lt;p&gt;See the following posts for more information:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/10/25/unit-testing-execution.aspx"&gt;Unit Testing: Execution&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/10/25/unit-testing-code-coverage.aspx"&gt;Unit Testing: Code Coverage&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Unit Testing: Testing Properties &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Populating a DataGridView from Xml Data</title><link>http://msmvps.com/blogs/deborahk/archive/2009/10/20/populating-a-datagridview-from-xml-data.aspx</link><pubDate>Tue, 20 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1733866</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;If you are using XML in a WinForms application you may find the need to display the XML data in a DataGridView. &lt;/p&gt;  &lt;p&gt;Let&amp;#39;s take this XML:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;lt;states&amp;gt;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;state name=&amp;quot;California&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;abbreviation&amp;gt;CA&amp;lt;/abbreviation&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;year&amp;gt;1850&amp;lt;/year&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;governor&amp;gt;Schwarzenegger&amp;lt;/governor&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;state name=&amp;quot;Wisconsin&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;abbreviation&amp;gt;WI&amp;lt;/abbreviation&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;year&amp;gt;1848&amp;lt;/year&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;governor&amp;gt;Doyle&amp;lt;/governor&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;lt;/states&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Displaying XML in a DataGridView sounds easy, but if you just set the DataGridView DataSource to the XML data, you will get something like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/6013.image_5F00_044D9E51.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/0552.image_5F00_thumb_5F00_62EDF8B4.png" width="469" height="184" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice how it has lots of yuck in it: attribute details, node properties, and so on for every node in the XML. So how do you get something more like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5758.image_5F00_3ADB4995.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/deborahk.metablogapi/5736.image_5F00_thumb_5F00_64DB47BD.png" width="463" height="203" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;The trick is to use anonymous types.&lt;/p&gt;  &lt;p&gt;The code is provided here in VB and C# and then described in detail below.&lt;/p&gt;  &lt;p&gt;NOTE: Be sure to set a reference to &lt;strong&gt;System.Core&lt;/strong&gt; and &lt;strong&gt;System.Xml.Linq&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;XElement statesXml = XElement.Parse(&amp;quot;&amp;lt;states&amp;gt;&amp;quot; +      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;state name=&amp;#39;California&amp;#39;&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;abbreviation&amp;gt;CA&amp;lt;/abbreviation&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;year&amp;gt;1850&amp;lt;/year&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;governor&amp;gt;Schwarzenegger&amp;lt;/governor&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;/state&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;state name=&amp;#39;Wisconsin&amp;#39;&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;abbreviation&amp;gt;WI&amp;lt;/abbreviation&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;year&amp;gt;1848&amp;lt;/year&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;governor&amp;gt;Doyle&amp;lt;/governor&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;quot;&amp;lt;/state&amp;gt;&amp;quot; +       &lt;br /&gt;&amp;#160;&amp;#160; &amp;quot;&amp;lt;/states&amp;gt;&amp;quot;); &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;var query = from st in statesXml.Descendants(&amp;quot;state&amp;quot;)      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; select new       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&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; Name = st.Attribute(&amp;quot;name&amp;quot;).Value,       &lt;br /&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; Abbrev = st.Element(&amp;quot;abbreviation&amp;quot;).Value,       &lt;br /&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; Year = st.Element(&amp;quot;year&amp;quot;).Value,       &lt;br /&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; Governor = st.Element(&amp;quot;governor&amp;quot;).Value       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };       &lt;br /&gt;DataGridView1.DataSource = query.ToList();&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Dim statesXml As XElement = _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;states&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;state name=&amp;quot;California&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;abbreviation&amp;gt;CA&amp;lt;/abbreviation&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;year&amp;gt;1850&amp;lt;/year&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;governor&amp;gt;Schwarzenegger&amp;lt;/governor&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;state name=&amp;quot;Wisconsin&amp;quot;&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;abbreviation&amp;gt;WI&amp;lt;/abbreviation&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;year&amp;gt;1848&amp;lt;/year&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;governor&amp;gt;Doyle&amp;lt;/governor&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/state&amp;gt;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;/states&amp;gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Dim query = From st In statesXml...&amp;lt;state&amp;gt; _      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Select New With { _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .Name = st.@name, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .Abbrev = st.&amp;lt;abbreviation&amp;gt;.Value, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .Year = st.&amp;lt;year&amp;gt;.Value, _       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; .Governor = st.&amp;lt;governor&amp;gt;.Value}       &lt;br /&gt;DataGridView1.DataSource = query.ToList&lt;/font&gt; &lt;/p&gt;  &lt;p&gt;The first part of this code builds the XML. The C# code uses the XElement.Parse function to build the XML; VB uses XML literals. This part of the code is not necessary if you are reading the XML from another source, such as a file.&lt;/p&gt;  &lt;p&gt;The second part of the code leverages Linq to XML to process the set of state XML elements. For each element, it uses the Select New syntax to create an anonymous type. The syntax defines an unnamed (anonymous) type with properties Name, Abbrev, Year, and Governor.&lt;/p&gt;  &lt;p&gt;[To view an overview of anonymous types, &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/08/19/anonymous-types-an-introduction.aspx"&gt;start here&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;The last line converts the results of the query to a generic list and assigns it to the DataSource property of the DataGridView. Visual Studio uses the anonymous type property names as the text for the column titles and populates the rows with each state element.&lt;/p&gt;  &lt;p&gt;Use this technique any time you have XML that you want to display in a DataGridView.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Visual Studio 2010 Beta 2 released</title><link>http://msmvps.com/blogs/joacim/archive/2009/10/20/visual-studio-2010-beta-2-released.aspx</link><pubDate>Tue, 20 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1733611</guid><dc:creator>Joacim</dc:creator><description>&lt;p&gt;Yesterday Microsoft had a big announcement day. At the same time as Steve Ballmer held his keynotes at the &lt;a href="http://www.mssharepointconference.com/pages/default.aspx" target="_blank"&gt;SharePoint Developers Conference&lt;/a&gt; (see the &lt;a href="http://www.mssharepointconference.com/pages/default.aspx" target="_blank"&gt;video&lt;/a&gt;) Microsoft released Visual Studio 2010 Beta 2 for MSDN subscribers, the public release will be tomorrow, October 21st. They also &lt;a href="http://blogs.msdn.com/somasegar/archive/2009/10/19/announcing-visual-studio-2010-and-net-fx-4-beta-2.aspx" target="_blank"&gt;announced that the official release date of Visual Studio 2010 and the .Net 4.0 Framework will be on March 22nd, 2010&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/joacim.metablogapi/4353.image_5F00_4D73D52B.png"&gt;&lt;img style="border-bottom:0px;border-left:0px;display:inline;margin-left:0px;border-top:0px;margin-right:0px;border-right:0px;" title="Visual Studio logo" border="0" alt="Visual Studio logo" align="right" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/joacim.metablogapi/5417.image_5F00_thumb_5F00_56EC93A1.png" width="261" height="39" /&gt;&lt;/a&gt; Visual Studio has been given a new blue-purple logo and at the same time the &lt;a href="http://msdn.microsoft.com/" target="_blank"&gt;MSDN web site&lt;/a&gt; has also been given a face lift using this blue-purple color scheme. If you have visited the &lt;a href="http://msdn.microsoft.com/vbasic" target="_blank"&gt;Visual Basic Developer Center&lt;/a&gt; recently you may have already seen the preview of the new MSDN look. In my opinion it’s much nicer compared to the old red color scheme it had before.&lt;/p&gt;  &lt;p&gt;With the beta release Microsoft also released &lt;a href="http://msdn.microsoft.com/en-us/sharepoint/default.aspx" target="_blank"&gt;Visual Studio 2010 Tools for SharePoint&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Microsoft have compiled a lot of 2010 resources on the VB and C# Developer Centers: &lt;a href="http://msdn.microsoft.com/en-us/vbasic/dd819153.aspx" target="_blank"&gt;VB 2010 Resources&lt;/a&gt;, &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/dd819407.aspx" target="_blank"&gt;C# 2010 Resources&lt;/a&gt;. They have also released a number of &lt;em&gt;How do I&lt;/em&gt; videos. &lt;strong&gt;Note&lt;/strong&gt;, the first two links will be available very soon, if they aren’t already.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;How Do I: &lt;a href="http://msdn.microsoft.com/vbasic/ee681550.aspx" target="_blank"&gt;Use auto-implemented properties?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;How Do I: &lt;a href="http://msdn.microsoft.com/vbasic/ee681551.aspx" target="_blank"&gt;Use implicit line continuations in VB 10?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;How Do I: &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee625744.aspx" target="_blank"&gt;Use highlight reference in the Visual Studio 2010 IDE?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;How Do I: &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee625748.aspx" target="_blank"&gt;Use Code Snippets in the Visual Studio IDE?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;How Do I: &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee633445.aspx" target="_blank"&gt;Use Generate from Usage in Visual Studio 2010?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;How Do I: &lt;a href="http://msdn.microsoft.com/en-us/vstudio/ee681649.aspx" target="_blank"&gt;Enhance performance in the Visual Studio 2010 IDE when editing VB code?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;How Do I: &lt;a href="http://msdn.microsoft.com/en-us/vcsharp/ee672313.aspx" target="_blank"&gt;Step with the debugger in Visual Studio?&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;How Do I: Refactor my code in Visual Studio (&lt;a href="http://msdn.microsoft.com/en-us/vbasic/ee672318.aspx" target="_blank"&gt;Part 1&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/vstudio/ee675607.aspx" target="_blank"&gt;Part 2&lt;/a&gt;)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I have looked forward to this beta release for a long time now, even though I have used Beta 1 since it was released back in May, beta 2 is much more promising simply because everything should be in place by now. Microsoft will probably not add any new features but rather just fix any bugs that are reported and concentrate on performance issues. So I can now start doing some real world testing and finally concentrate on to fully learn the new features of the framework. This of course also means that you can expect to see a lot more posts about VS2010 on this blog in the near future.&lt;/p&gt;  &lt;p&gt;Have fun, I know I will. :)&lt;/p&gt;</description></item><item><title>Nederlandse CodeCamp 2009</title><link>http://msmvps.com/blogs/theproblemsolver/archive/2009/10/19/nederlandse-codecamp-2009.aspx</link><pubDate>Mon, 19 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1732965</guid><dc:creator>Maurice</dc:creator><description>&lt;p&gt;Op 21 november 2009 organiseren de &lt;a href="http://www.sdn.nl"&gt;SDN&lt;/a&gt;, &lt;a href="http://www.dotned.nl"&gt;Stichting dotNed&lt;/a&gt; en &lt;a href="http://www.VBcentral.nl"&gt;VBcentral&lt;/a&gt; samen het derde Nederlandse &lt;a href="http://www.codecamp.nl"&gt;Code Camp&lt;/a&gt;. Dit is een dag lang met code, code sharing, freaking en gezellig samenzijn. Een evenement door ontwikkelaars, voor ontwikkelaars. De regie ligt voor een belangrijk deel bij de deelnemers! Het aantal plaatsen voor deelnemers is wel beperkt tot maximaal 150. Wacht dus niet te lang met beslissen want voor je het weet is er geen plaats meer. Vergeet bij je aanmelding niet op te geven welke onderwerpen je interesse hebben. Bovendien nodigen we iedereen graag uit om zelf een sessie in te vullen.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Op de website, &lt;a href="http://www.codecamp.nl"&gt;www.codecamp.nl&lt;/a&gt;, vind je meer informatie en kan je je aanmelden.&lt;/p&gt;</description></item><item><title>Lambda Expressions: Execution</title><link>http://msmvps.com/blogs/deborahk/archive/2009/10/16/lambda-expressions-execution.aspx</link><pubDate>Fri, 16 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1732784</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;Lambda expressions can be assigned to a delegate variable. The lambda expression is then executed when the delegate is called.&lt;/p&gt;  &lt;p&gt;[To begin with an overview of lambda expressions, &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/10/11/lambda-expressions-an-introduction.aspx"&gt;start here&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;In the following example, a lambda expression is assigned to a variable (f).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Func&amp;lt;int,string&amp;gt; f = &lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;x =&amp;gt; (x + x).ToString();      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;Debug.WriteLine(f(5));      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;Debug.WriteLine(f(10));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Dim f = Function(x as Integer) &lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;(x + x).ToString()      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;Debug.WriteLine(f(5))      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;Debug.WriteLine(f(10))&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The lambda expression in this example is a Func&amp;lt;int, string&amp;gt; [Func(Of Integer, String) in VB] meaning it takes one integer input parameter and returns a string. The lambda expression simply takes the input value, adds it to itself, and returns the result as a string.&lt;/p&gt;  &lt;p&gt;[For more information on Func delegates, see &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/10/11/lambda-expressions-func-delegates.aspx"&gt;this post&lt;/a&gt;.]&lt;/p&gt;  &lt;p&gt;When the expression is defined, it is &lt;em&gt;not&lt;/em&gt; executed. It is not executed until it is called.&lt;/p&gt;  &lt;p&gt;The first Debug.WriteLine statement calls the lambda expression, passing in a 5. The result displays &amp;quot;10&amp;quot; in the debug window.&lt;/p&gt;  &lt;p&gt;The second Debug.WriteLine statement calls the lambda expression again, passing in a 10. The result displays &amp;quot;20&amp;quot; in the debug window.&lt;/p&gt;  &lt;p&gt;Lambda expressions are executed when they are called, not when they are constructed. This is important to consider, especially when the lambda expression contains local variables. &lt;/p&gt;  &lt;p&gt;Local variables used in a lambda expression are “captured” or “lifted”. The variable value used is the value at &lt;em&gt;execution&lt;/em&gt; time. The variable lifetime extends to the lifetime of the delegate.&lt;/p&gt;  &lt;p&gt;The following code updates the original example to use a local variable.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;int y = 0;      &lt;br /&gt;Func&amp;lt;int,string&amp;gt; f = x =&amp;gt; (x + y).ToString();       &lt;br /&gt;y = 10;       &lt;br /&gt;Debug.WriteLine(f(5));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Dim y As Integer = 0      &lt;br /&gt;Dim f = Function(x) (x + y).ToString()       &lt;br /&gt;y = 10       &lt;br /&gt;Debug.WriteLine(f(5))&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;The lambda expression in this example takes the input value, adds it to the current value of the local variable (y), and returns the result as a string.&lt;/p&gt;  &lt;p&gt;The Debug.WriteLine statement in this example calls the lambda expression, passing in a 5.&amp;#160; At the point of executing the Debug statement, y is 10, so the result displays &amp;quot;15&amp;quot; in the debug window.&lt;/p&gt;  &lt;p&gt;For another example of using lambda expressions with local variables, see &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/07/02/lambda-expressions-finding-differences-in-two-lists.aspx"&gt;this post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Nationale Office Dag files</title><link>http://msmvps.com/blogs/theproblemsolver/archive/2009/10/15/nationale-office-dag-files.aspx</link><pubDate>Thu, 15 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1732609</guid><dc:creator>Maurice</dc:creator><description>&lt;p&gt;Looking for the slides and samples from my two presentations at the &lt;a href="http://www.nationaleofficedag.com/"&gt;Nationale Office Dag&lt;/a&gt; in Ede? You can download them from &lt;a href="http://www.theproblemsolver.nl/files/nod2009_presentaties.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.theproblemsolver.nl/"&gt;www.TheProblemSolver.nl &lt;/a&gt;   &lt;br /&gt;&lt;a href="http://wiki.windowsworkflowfoundation.eu/"&gt;Wiki.WindowsWorkflowFoundation.eu&lt;/a&gt;&lt;/p&gt;</description></item><item><title>WinForms User Controls 101</title><link>http://msmvps.com/blogs/deborahk/archive/2009/10/13/winforms-user-controls-101.aspx</link><pubDate>Tue, 13 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1732168</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;The same several questions often come up in the forums regarding the basics of building a user control with VB.NET or C#. The goal of this post is to answer those questions.&lt;/p&gt;  &lt;p&gt;There are three basic types of WinForms user controls that you can create:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Extended control &lt;/li&gt;    &lt;li&gt;Composite control &lt;/li&gt;    &lt;li&gt;Custom control &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Each of these are discussed below.&lt;/p&gt;  &lt;h2&gt;Extended Control&lt;/h2&gt;  &lt;p&gt;Use an extended control whenever you want to extend the behavior of &lt;strong&gt;one&lt;/strong&gt; particular control. Say for example that you want to build your own TextBox that only allows alphabetic characters. Or you want to build your own Button that has specific behaviors.&lt;/p&gt;  &lt;p&gt;The best thing about extended controls is that you automatically get all of the intrinsic behavior of the original control. All you need to do is add any extended functionality that you want for the control.&lt;/p&gt;  &lt;p&gt;To create this type of user control, follow these steps.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Right-click on the project and select Add | User Control. &lt;/li&gt;    &lt;li&gt;Name the user control and click Add. &lt;/li&gt;    &lt;li&gt;Do &lt;strong&gt;NOT&lt;/strong&gt; put anything on the design surface of the user control. &lt;/li&gt;    &lt;li&gt;Open the code behind file (UserControl1.cs). &lt;/li&gt;    &lt;li&gt;Modify the code to inherit from the control you are extending. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;public partial class UserControl1 : TextBox&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This example extends a TextBox control. Replace TextBox above with whatever WinForm control you want to extend.&lt;/p&gt;  &lt;p&gt;NOTE: After changing the Inherits statement, you may get an error on a line that begins with this.AutoScaleMode. If so, just delete that line. It is no longer needed now that you are inheriting from a control other than UserControl.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Right-click on the project and select Add | User Control. &lt;/li&gt;    &lt;li&gt;Name the user control and click Add. &lt;/li&gt;    &lt;li&gt;Do &lt;strong&gt;NOT&lt;/strong&gt; put anything on the design surface of the user control. &lt;/li&gt;    &lt;li&gt;Select the project in the Solution Explorer and click the Show All Files button in the Solution Explorer toolbar. &lt;/li&gt;    &lt;li&gt;Click on the plus sign to the left of the user control in Solution Explorer to view the nodes below it. &lt;/li&gt;    &lt;li&gt;Double-click on the designer file to open it. (UserControl1.Designer.vb) &lt;/li&gt;    &lt;li&gt;Modify the code to inherit from the control you are extending. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;Partial Class UserControl1      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Inherits TextBox&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This example extends a TextBox control. Replace TextBox above with whatever WinForm control you want to extend.&lt;/p&gt;  &lt;p&gt;NOTE: After changing the Inherits statement, you may get an error on a line that begins with Me.AutoScaleMode. If so, just delete that line. It is no longer needed now that you are inheriting from a control other than UserControl.&lt;/p&gt;  &lt;p&gt;Then add any additional behavior or functionality that you want in the extended control.&lt;/p&gt;  &lt;p&gt;The MSDN documentation provides an example of building an extended control using &lt;a href="http://msdn.microsoft.com/en-us/library/w2a8y03d.aspx" target="_blank"&gt;VB.NET here&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/5h0k2e6x.aspx" target="_blank"&gt;C# here&lt;/a&gt;.&lt;/p&gt;  &lt;h2&gt;Composite Control&lt;/h2&gt;  &lt;p&gt;A composite controls is so named because it is composed of multiple controls. Use this type of user control any time you want to build a control that combines a set of other controls. For example, you want to build a search control that contains a Textbox for entry of the text to search, Button to click to perform the search, and ListBox for the results of the search.&lt;/p&gt;  &lt;p&gt;The best thing about composite controls is that you can easily add any controls to the composite control using the design surface. &lt;/p&gt;  &lt;p&gt;However, because it is a composite control that inherits from UserControl, no properties, methods, or events from any of the underlying controls are exposed. This means that when you use the user control, you cannot set the Text property of the TextBox or respond to Button click events without writing some code.&lt;/p&gt;  &lt;p&gt;You basically have to write code to expose any property, method, or event that you need.&lt;/p&gt;  &lt;p&gt;To create this type of user control, follow these steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Right-click on the project and select Add | User Control. &lt;/li&gt;    &lt;li&gt;Name the user control and click Add. &lt;/li&gt;    &lt;li&gt;Put the controls you want onto the design surface. &lt;/li&gt;    &lt;li&gt;Expose any properties, methods, or events that you need. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;An example of generating events from a user control is provided in &lt;a href="http://msmvps.com/blogs/deborahk/archive/2009/07/22/user-control-events-in-vb-and-c.aspx" target="_blank"&gt;this post&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The MSDN documentation provides an example of building a composite control using &lt;a href="http://msdn.microsoft.com/en-us/library/c316f119.aspx" target="_blank"&gt;VB.NET here&lt;/a&gt; and &lt;a href="http://msdn.microsoft.com/en-us/library/a6h7e207.aspx" target="_blank"&gt;C# here&lt;/a&gt;.&lt;/p&gt;  &lt;h2&gt;Custom Control&lt;/h2&gt;  &lt;p&gt;A custom control is a control you create from the ground up including all control drawing and any unique behavior.&lt;/p&gt;  &lt;p&gt;To build a custom control, inherit from Control to get the basic behavior of a WinForms control. Then use the OnPaint event to render your custom user interface.&lt;/p&gt;  &lt;p&gt;The MSDN documentation provides an example of building a simple custom control &lt;a href="http://msdn.microsoft.com/en-us/library/649xahhe.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item><item><title>Delegates</title><link>http://msmvps.com/blogs/deborahk/archive/2009/10/11/delegates.aspx</link><pubDate>Sun, 11 Oct 2009 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1731685</guid><dc:creator>DeborahK</dc:creator><description>&lt;p&gt;A delegate is an object that holds a reference to a method with a particular parameter list and return type.&lt;/p&gt;  &lt;p&gt;It is basically like an object-oriented, type-safe function pointer.&lt;/p&gt;  &lt;p&gt;Delegates basically make it possible to treat methods as entities. You can then assign a delegate to a variable or pass it as a parameter. &lt;/p&gt;  &lt;p&gt;The classic delegate example uses events.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;HelloButton.Click += new EventHandler(HelloButton_Click);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Or the short-cut version of this code:&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;HelloButton.Click += HelloButton_Click;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;This passes the HelloButton_Click method to a new EventHandler delegate.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;AddHandler HelloButton.Click, AddressOf HelloButton_Click&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;In VB, the AddressOf assigns the address of the HelloButton_Click method to the delegate.&lt;/p&gt;  &lt;p&gt;Instead of using a named method for the delegate (in this example, a HelloButton_Click method), you can use a lambda expression.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In C#:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;HelloButton.Click += &lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;(s, ev) =&amp;gt;      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MessageBox.Show(&amp;quot;Hello World&amp;quot;);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;In VB:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#65402e" face="Consolas"&gt;AddHandler HelloButton.Click, &lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;Function(s, ev) _      &lt;br /&gt;&lt;/font&gt;&lt;font color="#65402e" face="Consolas"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MessageBox.Show(&amp;quot;Hello World&amp;quot;)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;In this case the lambda expression has two parameters: s (sender) and ev (eventArgs). When the Click event is generated on the HelloButton, the code displays the MessageBox.&lt;/p&gt;  &lt;p&gt;You can use a lambda expression (inline function) anywhere a delegate is required. However, if the function requires more than a few lines of code, a named method is the preferred and recommended technique.&lt;/p&gt;  &lt;p&gt;Enjoy!&lt;/p&gt;</description></item></channel></rss>