<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Interakting Blogs</title><link>http://blogs.interakting.co.uk/MainFeed.aspx</link><description>Innovate. Interact. Inspire.</description><generator>Subtext Version 1.9.4.78</generator><item><title>Security: Conducting a Security Review and why your designs should incorporate Defence-In-Depth?</title><link>http://blogs.interakting.co.uk/steve/archive/2008/07/04/Security-Conducting-a-Security-Review-and-why-your-designs-should.aspx</link><pubDate>Fri, 04 Jul 2008 02:55:45 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/steve/archive/2008/07/04/Security-Conducting-a-Security-Review-and-why-your-designs-should.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/steve/comments/323.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/steve/comments/commentRss/323.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/steve/archive/2008/07/04/Security-Conducting-a-Security-Review-and-why-your-designs-should.aspx#comment</comments><slash:comments>0</slash:comments><trackback:ping>http://blogs.interakting.co.uk/steve/services/trackbacks/323.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/steve/rss.aspx">Security: Conducting a Security Review and why your designs should incorporate Defence-In-Depth?</source><description>&lt;p&gt;I'm currently conducting a due-diligence review of a technical system.  The system is a classic distributed, two-tier system with data held centrally and business-logic delegated to an application tier.  I've been asked to perform a security analysis as part of my review.  I can't tell you anything about the project itself, for confidentiality (and security) reasons, but I thought I'd share some of the thought processes behind what I've been doing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Reviewing security&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The foremost rule of security assessment is to include the entire system.  Don't just look at technical aspects of security but also at non-technical risks.  Here's an example: a password is a common technical security measure, but if steps aren't taken to prevent users from posting their passwords on the Internet, then the password is useless, even if it regularly expires and uses strong password controls.&lt;/p&gt;
&lt;p&gt;There is a similar problem when security is not appropriately applied.  When there is a too restrictive or misunderstood technical security requirement, individuals will look for and often find a way round the problem, often by disobeying the very policies that are critical non-technical security measures.&lt;/p&gt;
&lt;p&gt;The solution?  Security measures must be appropriate, proportionate, understood and trusted.  If you don't get the buy-in of your users then these measures have no or else limited value.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Understanding the threats&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The second rule of security assessment is to address the organisation's blind-spots.  Legitimate users of systems are also potential attackers, sometimes intentionally, sometimes maliciously and sometimes they are simply applying their own pragmatism, "surely the business doesn't want me to spend all that time jumping through these policy hoops?  I can save the company money if I do it like this...".&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Create buy-in&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Next, make sure that you employ security measures that your legitimate users are willing to employ.  There is no value in creating 60 character random passwords.  Your users will never remember them and so they'll write them down.  Probably, they'll leave them next to the computer as well...&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Implement Defence-In-Depth&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Defence-In-Depth is the principle of checking security at each component of a system.  It ensures that a breach in an outer component doesn't automatically gain unrestricted access to the assets at a deeper level.  In my analysis I found that this principle had not been applied and that meant that a breach at the outermost level could result in unrestricted access to substantially more data than a user was normally entitled to.&lt;/p&gt;
&lt;p&gt;Another resulting effect of the Defence-In-Depth approach is that it allows for clear security boundaries to be applied.  Within the data centre the organisation has effective security capabilities but once the data has left this secure area the degree of control is reduced.&lt;/p&gt;
&lt;p&gt;So how does Defence-In-Depth compare in a two-tier system?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Without Defence-In-Depth&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this scenario, all security checks are performed only once at the application layer, the communication layer or the data layer.  Let's look at the implication of each option in turn:&lt;/p&gt;
&lt;p&gt;&lt;u&gt;1.  Controls at the application layer only&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;In this case, if a user can breach the communication mechanism or the application code, then the user gains total access to all data in the system.  This presents some major difficulties from a security perspective as it can be relatively easy to break one or both of these using reverse-engineering or eavesdropping approaches.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;2.  Controls at the communication layer only&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;Securing the communication layer alone allows users to have complete access to the data and to do anything with it.  This provides no protection whatsoever from the insider, and that includes anyone who manages to break into the environment.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;3.  Controls at the data layer only&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;In this case, the access to data can be secured, however the data may be misused or transferred outside of the application.  The security at the data layer must be substantially hardened to prevent malicious users from causing unintended behaviour.  Once the data has left the data centre, the organisation no longer has any control over it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;With Defence-In-Depth&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The Defence-In-Depth approach is pessimistic.  It chooses to secure all three layers used in this system:&lt;/p&gt;
&lt;p&gt;&lt;u&gt;1.  Controls at the application layer first&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;This limits those allowed to use the application.  If it is breached, the user still has to break both the communication layer and the data layer security mechanisms.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;2.  Controls at the communication layer&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;This provides two added benefits.  Firstly, it limits the potential to break the application because the application's communications are encrypted.  Correct protocols can also prevent replay attacks and man-in-the-middle attacks.&lt;/p&gt;
&lt;p&gt;Secondly, it enables the data layer to only allow access through this secure medium, limiting its exposure to other systems.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;3.  Controls at the data layer&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;The data layer ensures that the application only has access to the data that the application's user is entitled to.  This limits the exposure of data.  Because the other two layers have hardened the access mechanism, the data layer is less susceptible to direct attacks using otherwise valid credentials.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Applying Defence-In-Depth won't solve all your problems, and it will introduce additional design complexity.  However, it should be applied to distributed systems where security is an imperative.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Metadata&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Categories: Business, Security, Software Development &lt;/li&gt;
    &lt;li&gt;Additional keywords: Defence In Depth, security policy, secure design &lt;/li&gt;
    &lt;li&gt;Technorati Tags: &lt;a rel="tag" href="http://technorati.com/tags/software%20development"&gt;software development&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/business"&gt;business&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/strategy"&gt;strategy&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/best%20practice"&gt;best practice&lt;/a&gt;, &lt;a rel="tag" href="http://technorati.com/tags/security"&gt;security&lt;/a&gt; &lt;a rel="tag" href="http://technorati.com/tags/security%20review"&gt;security review&lt;/a&gt; &lt;a rel="tag" href="http://technorati.com/tags/defence-in-depth"&gt;Defence-In-Depth&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.interakting.co.uk/steve/aggbug/323.aspx" width="1" height="1" /&gt;</description><dc:creator>Stephen Horsfield</dc:creator></item><item><title>Choosing the best way to compare text to empty strings</title><link>http://blogs.interakting.co.uk/dominicz/archive/2008/07/03/Choosing-the-best-way-to-compare-text-to-empty-strings.aspx</link><pubDate>Thu, 03 Jul 2008 00:45:19 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/dominicz/archive/2008/07/03/Choosing-the-best-way-to-compare-text-to-empty-strings.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/dominicz/comments/322.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/dominicz/comments/commentRss/322.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/dominicz/archive/2008/07/03/Choosing-the-best-way-to-compare-text-to-empty-strings.aspx#comment</comments><slash:comments>0</slash:comments><trackback:ping>http://blogs.interakting.co.uk/dominicz/services/trackbacks/322.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/dominicz/rss.aspx">Choosing the best way to compare text to empty strings</source><description>&lt;p&gt;I don’t know about you, but when I’ve seen some string comparisons, some people use: &lt;/p&gt;  &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;   &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;     &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; text = GetStringFromDB() &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;if&lt;/span&gt;( text != &lt;span style="color: #0000ff"&gt;string&lt;/span&gt;.Empty ) &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    DoThis(); &lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This looks good, but its actually quite a long running process, as the CLR has to compare both strings character by character. It is much better to use String.IsNullOrEmpty to cater for this, or use .Length == 0 property, as this never changes and is computed when assigned. Here is what the String.IsNullOrEmpty method looks like: &lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; IsNullOrEmpty(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;{&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;value&lt;/span&gt; != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;value&lt;/span&gt;.Length == 0);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;}&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;If you use != , or  ==, or .Equals() the method, it uses some hefty pointer manipulation like this: &lt;/p&gt;

&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; background-color: #f4f4f4"&gt;
  &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;
    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Equals(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;{&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((&lt;span style="color: #0000ff"&gt;value&lt;/span&gt; == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;) &amp;amp;&amp;amp; (&lt;span style="color: #0000ff"&gt;this&lt;/span&gt; != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;))&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; EqualsHelper(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;}&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&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;unsafe&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; EqualsHelper(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; strA, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; strB)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;{&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; length = strA.Length;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (length != strB.Length)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt; &lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    &lt;span style="color: #0000ff"&gt;fixed&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* str = ((&lt;span style="color: #0000ff"&gt;char&lt;/span&gt;*) strA))&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;    {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* chPtr = str;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;        &lt;span style="color: #0000ff"&gt;fixed&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* str2 = ((&lt;span style="color: #0000ff"&gt;char&lt;/span&gt;*) strB))&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;        {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* chPtr2 = str2;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* chPtr3 = chPtr;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;char&lt;/span&gt;* chPtr4 = chPtr2;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;while&lt;/span&gt; (length &amp;gt;= 10)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; ((((*(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) chPtr3)) != *(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) chPtr4))) || (*(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr3 + 2))) != *(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr4 + 2))))) || ((*(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr3 + 4))) != *(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr4 + 4)))) || (*(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr3 + 6))) != *(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr4 + 6)))))) || (*(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr3 + 8))) != *(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) (chPtr4 + 8)))))&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                    &lt;span style="color: #0000ff"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                chPtr3 += 10;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                chPtr4 += 10;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                length -= 10;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;while&lt;/span&gt; (length &amp;gt; 0)&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (*(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) chPtr3)) != *(((&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;*) chPtr4)))&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                {&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                    &lt;span style="color: #0000ff"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                chPtr3 += 2;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;                chPtr4 += 2;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;                length -= 2;&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;            }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;            &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; (length &amp;lt;= 0);&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;        }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;    }&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;}&lt;/pre&gt;

    &lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt; &lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;So in essence, don’t use != because &lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;It is massively slower &lt;/li&gt;

  &lt;li&gt;It doesn’t take culture into consideration. &lt;/li&gt;

  &lt;li&gt;It caters for 2 cases instead of 1 – what would you do if the string was null? &lt;/li&gt;
&lt;/ol&gt;&lt;img src="http://blogs.interakting.co.uk/dominicz/aggbug/322.aspx" width="1" height="1" /&gt;</description><dc:creator>Dominic</dc:creator></item><item><title>Problems serializing a generic list using SoapFormatter</title><link>http://blogs.interakting.co.uk/ray/archive/2008/07/02/321.aspx</link><pubDate>Wed, 02 Jul 2008 01:22:43 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/ray/archive/2008/07/02/321.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/ray/comments/321.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/ray/comments/commentRss/321.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/ray/archive/2008/07/02/321.aspx#comment</comments><slash:comments>0</slash:comments><trackback:ping>http://blogs.interakting.co.uk/ray/services/trackbacks/321.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/ray/rss.aspx">Problems serializing a generic list using SoapFormatter</source><description>&lt;p&gt;Just recently I have been studying for my MCTS foundation exam and as part of this I had created a windows for application for calculating golf scores. As part of this application I was storing the information in a generic list of a custom Person class. I decided to extend the functionality by allowing the user to export and import the information and thought it would be an ideally opportunity to practice serialization. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;At first I was using a binary formatter and everything worked fine, however I decided to try using the SoapFormatter instead. I changed the code to use SoapFormatter and expected everything would just work as I had test it using the binary formatter but when I ran the program I got an error saying&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;"Soap Serializer does not support serializing Generic Types : System.Collections.Generic.List`1[GolfScores.Person]."&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;After spending some time researching the problem I found an interesting discussion on the MSDN forum about this error, &lt;a title="http://forums.msdn.microsoft.com/en-US/netfxremoting/thread/ee4a7a63-290e-432f-bd45-44f4cb7a3467/" href="http://forums.msdn.microsoft.com/en-US/netfxremoting/thread/ee4a7a63-290e-432f-bd45-44f4cb7a3467/"&gt;http://forums.msdn.microsoft.com/en-US/netfxremoting/thread/ee4a7a63-290e-432f-bd45-44f4cb7a3467/&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;Apparently there are ways around this but for the purposes of my golf application I was able to use the XmlSerializer. Most people use generics these days so its something to consider when you are looking to use the to serialize information stored in a generic list.&lt;/p&gt;&lt;img src="http://blogs.interakting.co.uk/ray/aggbug/321.aspx" width="1" height="1" /&gt;</description><dc:creator>Raymond Little</dc:creator></item><item><title>Making decisions easier for null values with the ?? (null coalescing) operator</title><link>http://blogs.interakting.co.uk/dominicz/archive/2008/07/01/Making-decisions-easier-for-null-values-with-the--null-coalescing-operator.aspx</link><pubDate>Tue, 01 Jul 2008 06:50:42 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/dominicz/archive/2008/07/01/Making-decisions-easier-for-null-values-with-the--null-coalescing-operator.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/dominicz/comments/320.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/dominicz/comments/commentRss/320.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/dominicz/archive/2008/07/01/Making-decisions-easier-for-null-values-with-the--null-coalescing-operator.aspx#comment</comments><slash:comments>0</slash:comments><trackback:ping>http://blogs.interakting.co.uk/dominicz/services/trackbacks/320.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/dominicz/rss.aspx">Making decisions easier for null values with the ?? (null coalescing) operator</source><description>&lt;p&gt;When catering for null values, I use the ternary operator ?, which is used to do an inline IF statement. For example:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; CheckText(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; text)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(String.IsNullOrEmpty(text))&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ArgumentException(&lt;span style="color: rgb(0, 96, 128);"&gt;"Parameter is "&lt;/span&gt; + (text==&lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt; ? &lt;span style="color: rgb(0, 96, 128);"&gt;"null."&lt;/span&gt; : &lt;span style="color: rgb(0, 96, 128);"&gt;"empty."&lt;/span&gt;));&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;//Other code here&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This would allow you to cater for 2 exception cases:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;When the parameter is null, the exception message states "Parameter is null."; &lt;/li&gt;
    &lt;li&gt;When the parameter is "", the exception message states "Parameter is empty."; &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Since testing for null is a fairly common operation, and also catering for the possibility of a null, there is an operator called the &lt;em&gt;null coalescing&lt;/em&gt; operator. The operator is used to check a value for null, and return an alternative value if the result is null&lt;/p&gt;
&lt;p&gt;Before:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; text = ReadFromDB();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;(text == &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    Console.WriteLine(&lt;span style="color: rgb(0, 96, 128);"&gt;"(null)"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    Console.WriteLine(text);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;After:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; text = ReadFromDB();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;Console.WriteLine( text ?? &lt;span style="color: rgb(0, 96, 128);"&gt;"(null)"&lt;/span&gt; );&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;So, the way it works is it checks the first variable. If it is not null it returns the first variable, otherwise it returns the second. It is a shorthand method of this made up method:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;static&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; GetObject(&lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; o, &lt;span style="color: rgb(0, 0, 255);"&gt;object&lt;/span&gt; _default)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;( o == &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt; )&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;          &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;_default&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; o;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;//Or return (o==null?_default:o);&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The main use of this would be for outputting data to a table, or to a stream - but it looks like something I will definitely use in the future, instead of my long winded ternary operators ?&lt;/p&gt;&lt;img src="http://blogs.interakting.co.uk/dominicz/aggbug/320.aspx" width="1" height="1" /&gt;</description><dc:creator>Dominic</dc:creator></item><item><title>Restoring a site tree in ADAM</title><link>http://blogs.interakting.co.uk/ray/archive/2008/06/23/317.aspx</link><pubDate>Mon, 23 Jun 2008 04:34:57 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/ray/archive/2008/06/23/317.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/ray/comments/317.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/ray/comments/commentRss/317.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/ray/archive/2008/06/23/317.aspx#comment</comments><slash:comments>0</slash:comments><trackback:ping>http://blogs.interakting.co.uk/ray/services/trackbacks/317.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/ray/rss.aspx">Restoring a site tree in ADAM</source><description>&lt;p&gt;Recently one of our clients wanted to update their staging environment with the content from live so they could test with up to real content. Having done this before I thought this would be an easy job, however I found a slight issue with the restore process.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;When performing the back up one of the parameters allows you to specify if you are exporting from AD/AM. What the documentation doesn't tell you is you also have to specify this when you are trying to restore the back up. If you don't include this you get an extremely unhelpful 'Index out of range. Must be non-negative and less than the size of the collection' error.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I spent a good while checking the command, checking the XML that was generated, changing the parameters to try and identify what section was causing the problem until I double checked the command line help and spotted the /ADAM parameter. Initially I didn't think this would be the issue as I assumed that there would be a more helpful error message if you missed out the switch but no as soon as I added this everything worked fine.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Hopefully this will save you some time if you encounter this problem. &lt;/p&gt;&lt;img src="http://blogs.interakting.co.uk/ray/aggbug/317.aspx" width="1" height="1" /&gt;</description><dc:creator>Raymond Little</dc:creator></item><item><title>Create your own configuration settings with ConfigurationSetting</title><link>http://blogs.interakting.co.uk/dominicz/archive/2008/06/23/Create-your-own-configuration-settings-with-ConfigurationSetting.aspx</link><pubDate>Mon, 23 Jun 2008 02:17:40 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/dominicz/archive/2008/06/23/Create-your-own-configuration-settings-with-ConfigurationSetting.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/dominicz/comments/316.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/dominicz/comments/commentRss/316.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/dominicz/archive/2008/06/23/Create-your-own-configuration-settings-with-ConfigurationSetting.aspx#comment</comments><slash:comments>0</slash:comments><trackback:ping>http://blogs.interakting.co.uk/dominicz/services/trackbacks/316.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/dominicz/rss.aspx">Create your own configuration settings with ConfigurationSetting</source><description>&lt;p&gt;I remember a while ago writing an application and wanting to feed in some configuration settings. I was just using AppSettings, but the problem was that all settings were strings, so I had to cast several variables, and write loads of error checking just to get the application up and running.&lt;/p&gt;
&lt;p&gt;The application in question had several settings including a mixture of booleans, integers and strings. I had to parse them and then error check these values, to make the application more stable. It did create a heap of try/catch blocks that, as you will see are now unnecessary. Here is how the application used to work:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; Initialize()&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; timeout = 0;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;.TryParse(ConfigurationManager.AppSettings[&lt;span style="color: rgb(0, 96, 128);"&gt;"Timeout"&lt;/span&gt;], &lt;span style="color: rgb(0, 0, 255);"&gt;out&lt;/span&gt; timeout))&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (timeout &amp;lt; 0)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ConfigurationErrorsException(&lt;span style="color: rgb(0, 96, 128);"&gt;"Timeout must be &amp;gt;= 0"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;            &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Timeout = timeout;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;throw&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; ConfigurationErrorsException(&lt;span style="color: rgb(0, 96, 128);"&gt;"Timeout is not a valid integer"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    ...&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Now, although this is quite extensive error checking, the reasoning behind it is purely because we are dealing with strings. Can't the .NET framework do this for us!? YES!&lt;/p&gt;
&lt;p&gt;In .NET 2.0, they have made it so easy to have your own Configuration Sections, and even making them type safe too! All with the help of the System.Configuration.ConfigurationSection (in System.Configuration.dll, not in System.dll).&lt;/p&gt;
&lt;p&gt;All we have to do is create a class that inherits from System.Configuration.ConfigurationSection and then apply a couple of attributes! Then, we can give this class meaningful property names.&lt;/p&gt;
&lt;p&gt;There are 4 steps to this:&lt;/p&gt;
&lt;ol&gt;
    &lt;li&gt;Create an entry in your Configuration file to hold the data&lt;/li&gt;
    &lt;li&gt;Create a class to read the settings into&lt;/li&gt;
    &lt;li&gt;Create an entry in your Configuration file to tell the CLR what class will it read the information info.&lt;/li&gt;
    &lt;li&gt;Read the section from the ConfigurationManager (or WebConfigurationManager).&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Create an entry in your Configuration file to hold the data&lt;/h3&gt;
&lt;p&gt;I would like to declare my XML like this: &lt;br /&gt;
&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;UseWebService&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;available&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="true"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;timeToRespond&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="100"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;address&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="http://www.tempuri.org"&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Create a class to read the settings into&lt;/h3&gt;
&lt;p&gt; So lets say we want to store:&lt;/p&gt;
&lt;ul&gt;
    &lt;li&gt;Enabled = Bool, must be defined &lt;/li&gt;
    &lt;li&gt;Timeout = Integer, Must be &amp;gt;= 0 &lt;/li&gt;
    &lt;li&gt;Url = string, optional &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We just create a class that inherits from System.Configuration.ConfigurationSection and declare these properties, and use get/set to set the values on the base class.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Therefore I will assign the "available" in the property "Enabled", "timeToRespond" to "Timeout" and "address" to "Url".&lt;/p&gt;
&lt;p&gt;Firstly, I'll create my class. Notice that I'm not using the same text as the attribute in the XML - e.g. I use base["enabled"] instead of base["available"] ... This will be explained shortly.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; UseWebServiceSection : ConfigurationSection&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; Enabled&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;      get { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt;)&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"enabled"&lt;/span&gt;]; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;      set { &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"enabled"&lt;/span&gt;] = &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; Timeout&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;         get { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"timeout"&lt;/span&gt;]; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;         set { &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"timeout"&lt;/span&gt;] = &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; Url&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;         get { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;)&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"url"&lt;/span&gt;]; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;         set { &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"url"&lt;/span&gt;] = &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt; }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This isn't enough. We're assigning the values, but the class can actually pull the values out and assign them for us with the use of the ConfigurationPropertyAttribute. &lt;em&gt;This attribute allows us to assign which XML attribute will be bound to the property, but also set up default values too!&lt;/em&gt; So lets apply it to these values:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; UseWebServiceSection : ConfigurationSection&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;{     &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    [ConfigurationProperty(&lt;span style="color: rgb(0, 96, 128);"&gt;"available", &lt;/span&gt;&lt;strong&gt;IsRequired&lt;/strong&gt;= &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;, DefaultValue = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; Enabled    &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    {      &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;        get { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt;)&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"enabled"&lt;/span&gt;]; }      &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;        set { &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"enabled"&lt;/span&gt;] = &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt; }    &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt; &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    [ConfigurationProperty(&lt;span style="color: rgb(0, 96, 128);"&gt;"timeToRespond"&lt;/span&gt;, IsRequired = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; Timeout    &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    {         &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;        get { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt;)&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"timeout"&lt;/span&gt;]; }         &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;        set { &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"timeout"&lt;/span&gt;] = &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt; }    &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    }     &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    [ConfigurationProperty(&lt;span style="color: rgb(0, 96, 128);"&gt;"address"&lt;/span&gt;, IsRequired = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; Url    &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    {         &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;        get { &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;)&lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"url"&lt;/span&gt;]; }         &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;        set { &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;[&lt;span style="color: rgb(0, 96, 128);"&gt;"url"&lt;/span&gt;] = &lt;span style="color: rgb(0, 0, 255);"&gt;value&lt;/span&gt; }    &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Lastly, there is a requirement that the Timeout field NEEDS to be &amp;gt;=0. So, we can use the IntegerValidatorAttribute to check this for us.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;[IntegerValidator(MinValue=0)]&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;[ConfigurationProperty(&lt;span style="color: rgb(0, 96, 128);"&gt;"timeToRespond"&lt;/span&gt;,IsRequired=&lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; Timeout&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;{&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;    &lt;span style="color: rgb(0, 128, 0);"&gt;//As above&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Create an entry in your Configuration file to tell the CLR what class will it read the information info&lt;/h3&gt;
&lt;p&gt;The most important part - the configuration file needs to know how to deal with this new section.&lt;/p&gt;
&lt;p&gt;The configuration file has a section called "configSections". This element contains the definition for your new section, and what class to process it with. In our case it would look like:&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;configuration&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;configSections&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;        &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;section&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;="UseWebService"&lt;/span&gt; &lt;span style="color: rgb(255, 0, 0);"&gt;type&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;"UseWebServiceSection, MyNamespace.UseWebServiceSection"&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;    &lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;configSection&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(128, 0, 0);"&gt;configuration&lt;/span&gt;&lt;span style="color: rgb(0, 0, 255);"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Read the section from the ConfigurationManager (or WebConfigurationManager).&lt;/h3&gt;
&lt;p&gt;Finally, the section now needs to be pulled out of the Configuration file.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;UseWebServiceSection webService = (UseWebServiceSection)ConfigurationManager.GetSection(&lt;span style="color: rgb(0, 96, 128);"&gt;"UseWebService"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;Console.WriteLine(&lt;span style="color: rgb(0, 96, 128);"&gt;"available = {0}"&lt;/span&gt;,webService.Enabled);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;Console.WriteLine(&lt;span style="color: rgb(0, 96, 128);"&gt;"timeToRespond = {0}"&lt;/span&gt;,webService.Timeout);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;Console.WriteLine(&lt;span style="color: rgb(0, 96, 128);"&gt;"address = {0}"&lt;/span&gt;,webService.Url);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;Having the ConfigurationSection class immensely simplifies creating type-safe configuration sections. It seems like a lot of work, but it isn't really. Just create a class, create your XML, add a section in the .config and then write a bit of code. Its easy when you know how!&lt;/p&gt;
&lt;p&gt;In a later article, I will explain how you can write inner elements rather than just using attributes on one level.&lt;/p&gt;&lt;img src="http://blogs.interakting.co.uk/dominicz/aggbug/316.aspx" width="1" height="1" /&gt;</description><dc:creator>Dominic</dc:creator></item><item><title>NickServ and HydraIRC</title><link>http://blogs.interakting.co.uk/danmatthews/archive/2008/06/23/NickServ-and-HydraIRC.aspx</link><pubDate>Mon, 23 Jun 2008 01:11:59 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/danmatthews/archive/2008/06/23/NickServ-and-HydraIRC.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/danmatthews/comments/315.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/danmatthews/comments/commentRss/315.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/danmatthews/archive/2008/06/23/NickServ-and-HydraIRC.aspx#comment</comments><slash:comments>1</slash:comments><trackback:ping>http://blogs.interakting.co.uk/danmatthews/services/trackbacks/315.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/danmatthews/rss.aspx">NickServ and HydraIRC</source><description>&lt;p&gt;I've been hanging out on the &lt;a href="http://stevecelius.spaces.live.com/blog/cns!758863CB279D3EB1!299.entry" target="_blank"&gt;#epicode&lt;/a&gt; IRC channel for the past few months, and over time I've played with several IRC clients such as &lt;a href="http://www.xchat.org/" target="_blank"&gt;XChat&lt;/a&gt;, &lt;a href="http://www.mibbit.com/" target="_blank"&gt;Mibbit&lt;/a&gt; (for the Web) and &lt;a href="http://www.hydrairc.com/" target="_blank"&gt;HydraIRC&lt;/a&gt;. One of the things that you do most often on IRC is /msg people. The server that I use for #epicode is FreeNode. This server requires you to register you nick before doing a /msg. If you try to /msg without registering, you get an error message back from the server. XChat, annoyingly, didn't show me the IRC error and I spent quite some time trying to figure out what was wrong. Mibbit behaves nicely, but you have to enter your credentials every time which is a pain. (tip: on Mibbit,  click the 'Auth' link next to the server dropdown on the main page and you can enter your NickServ password straight in there!) HydraIRC behaves nicely too, but I've been having problems getting it to store my NickServ password so I don't have to enter it every time.&lt;/p&gt;  &lt;p&gt;In theory, the password is saved by HydraIRC when you create a favourite, but it doesn't seem to work for channel favourites, only server favourites. No, I've no idea why. If you look in the XML profile file in the HydraIRC installation directory all the information looks correct. Maybe they work for you but they sure are a pain for me. Thankfully, there is an easy workaround. HydraIRC has a bit of a hack called &lt;a href="http://www.hydrairc.com/wiki/wakka.php?wakka=CommandProfiles&amp;amp;v=ydf" target="_blank"&gt;Command Profiles&lt;/a&gt;. I wouldn't describe them as a well-documented feature but they do the trick. Essentially a command profile is just a set of IRC commands that can be run automatically when you connect to a particular IRC server. You can find the command profiles by going Options -&amp;gt; Prefs... -&amp;gt; Command Profiles. In there, you create a profile using a special name so that is picked up on logging in to a server. The name, in my case, is FreeNode_OnLoggedIn. Within that I simply put in my NickServ identification.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.interakting.co.uk/images/blogs_interakting_co_uk/danmatthews/WindowsLiveWriter/NickServandHydraIRC_9DBB/hydracps_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="375" alt="hydracps" src="http://blogs.interakting.co.uk/images/blogs_interakting_co_uk/danmatthews/WindowsLiveWriter/NickServandHydraIRC_9DBB/hydracps_thumb.jpg" width="519" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;When I go to my #epicode channel favourite now, it automatically runs my identification with NickServ so that I can /msg people without the pesky error message and having to register myself manually with NickServ every time!&lt;/p&gt;&lt;img src="http://blogs.interakting.co.uk/danmatthews/aggbug/315.aspx" width="1" height="1" /&gt;</description><dc:creator>Dan Matthews</dc:creator></item><item><title>Creating Templates for use in server controls</title><link>http://blogs.interakting.co.uk/ray/archive/2008/06/17/314.aspx</link><pubDate>Tue, 17 Jun 2008 01:38:55 GMT</pubDate><guid isPermaLink="true">http://blogs.interakting.co.uk/ray/archive/2008/06/17/314.aspx</guid><wfw:comment>http://blogs.interakting.co.uk/ray/comments/314.aspx</wfw:comment><wfw:commentRss>http://blogs.interakting.co.uk/ray/comments/commentRss/314.aspx</wfw:commentRss><comments>http://blogs.interakting.co.uk/ray/archive/2008/06/17/314.aspx#comment</comments><slash:comments>0</slash:comments><trackback:ping>http://blogs.interakting.co.uk/ray/services/trackbacks/314.aspx</trackback:ping><source url="http://blogs.interakting.co.uk/ray/rss.aspx">Creating Templates for use in server controls</source><description>&lt;p&gt;Normally when I am creating a website I tend to create the main functionality in  user controls, which I can then place on the appropriate pages. This approach is easy as you can use the ascx page to set the mark up of what has to appear on the page and write your vb or c# code to perform the bulk of the work. &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Recently I decided that I should spend some time using server controls instead as I didn't have much practical experience using them. It was only when I starting creating server controls to replicate simple functionality I had earlier created in user controls that I realised how much extra effort is required. A prime example of this is creating either item, header or footer templates for use in things like repeaters.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Below is an example of code for an aspx page from the msdn site on the standard use for a repeater, including the markup for the different templates.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &amp;lt;asp:Repeater id=&lt;span style="color: rgb(0, 96, 128);"&gt;"Repeater1"&lt;/span&gt; runat=&lt;span style="color: rgb(0, 96, 128);"&gt;"server"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;           &amp;lt;HeaderTemplate&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;              &amp;lt;table border=&lt;span style="color: rgb(0, 96, 128);"&gt;"1"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;                 &amp;lt;tr&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;                    &amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Company&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;                    &amp;lt;td&amp;gt;&amp;lt;b&amp;gt;Symbol&amp;lt;/b&amp;gt;&amp;lt;/td&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;                 &amp;lt;/tr&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;           &amp;lt;/HeaderTemplate&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;  &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;           &amp;lt;ItemTemplate&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;              &amp;lt;tr&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;                 &amp;lt;td&amp;gt; &amp;lt;%# DataBinder.Eval(Container.DataItem, &lt;span style="color: rgb(0, 96, 128);"&gt;"Name"&lt;/span&gt;) %&amp;gt; &amp;lt;/td&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;                 &amp;lt;td&amp;gt; &amp;lt;%# DataBinder.Eval(Container.DataItem, &lt;span style="color: rgb(0, 96, 128);"&gt;"Ticker"&lt;/span&gt;) %&amp;gt; &amp;lt;/td&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;              &amp;lt;/tr&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;           &amp;lt;/ItemTemplate&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;  &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;           &amp;lt;FooterTemplate&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;              &amp;lt;/table&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;           &amp;lt;/FooterTemplate&amp;gt;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;  &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;        &amp;lt;/asp:Repeater&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It is all very straight forward you create a repeater then very simply you can set what has to appear in the various templates. The difference with server controls is you need to create this all manually. Not only do you actually need to create an instance of the repeater in code and set all the properties you also need to manually create a class for each template and then set the repeater templates to use your new classes.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;First I will create a new templates for the header, footer and item. Next I will then show you how to set the repeater to use the new templates. The first template I created was the header template and basically in here we need to consider what we are trying to achieve. In this case I wanted an unordered list of items so to create the appropriate markup I simply want my header template to open the unordered list.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; CustomHeaderTemplate : ITemplate&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; InstantiateIn(System.Web.UI.Control container)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;         {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;             Literal Lt_Header = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Literal();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;             Lt_Header.ID = &lt;span style="color: rgb(0, 96, 128);"&gt;"Lt_Header"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;             Lt_Header.Text = &lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;lt;ul&amp;gt;"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;                         &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;             container.Controls.Add(Lt_Header);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The key aspects of this are the &lt;strong&gt;class must implement the ITemplate interface&lt;/strong&gt; otherwise you won't be able to set the repeater to use this. The other crucial section is remembering to &lt;strong&gt;add the control you create, in this case my Literal, to the container&lt;/strong&gt;, which will be a repeater, otherwise it won't show. Apart from these two the code is very straight forward so I will move on to creating the footer template.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The footer template is almost identical to the header except this time I want to close the unordered list instead of opening it.&lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; CustomFooterTemplate : ITemplate&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; InstantiateIn(System.Web.UI.Control container)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;         {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;             Literal Lt_Footer = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Literal();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;             Lt_Footer.ID = &lt;span style="color: rgb(0, 96, 128);"&gt;"Lt_Footer"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;             Lt_Footer.Text = &lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;lt;/ul&amp;gt;"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;  &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;             container.Controls.Add(Lt_Footer);&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The final template I will look at is the item template and this is the one where the majority of work needs done. &lt;/p&gt;
&lt;div style="border: 1px solid gray; margin: 20px 0px 10px; padding: 4px; overflow: auto; font-size: 8pt; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; CustomItemTemplate : ITemplate, INamingContainer&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;         &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; InstantiateIn(System.Web.UI.Control container)&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;         {            &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;                 Literal LtOpenElement = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Literal();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;             LtOpenElement.ID = &lt;span style="color: rgb(0, 96, 128);"&gt;"LtOpenElement"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;             LtOpenElement.Text = &lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;lt;li&amp;gt;"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;  &lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;             Literal LtClosingElement = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Literal();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;             LtClosingElement.ID = &lt;span style="color: rgb(0, 96, 128);"&gt;"LtClosingElement"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;             LtClosingElement.Text = &lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;lt;/li&amp;gt;"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;             Label LblDate = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; Label();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;             HyperLink HypLink = &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; HyperLink();&lt;/pre&gt;
&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background