<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>this.Pose() as Expert - BCL</title>
    <link>http://chrison.net/</link>
    <description />
    <language>en-us</language>
    <copyright>Christoph Wille</copyright>
    <lastBuildDate>Wed, 08 Nov 2006 14:04:26 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>christoph.wille@gmail.com</managingEditor>
    <webMaster>christoph.wille@gmail.com</webMaster>
    <item>
      <trackback:ping>http://chrison.net/Trackback.aspx?guid=12cc87b1-a461-442f-8a49-7eff8aea58dd</trackback:ping>
      <pingback:server>http://chrison.net/pingback.aspx</pingback:server>
      <pingback:target>http://chrison.net/PermaLink,guid,12cc87b1-a461-442f-8a49-7eff8aea58dd.aspx</pingback:target>
      <dc:creator>Christoph Wille</dc:creator>
      <wfw:comment>http://chrison.net/CommentView,guid,12cc87b1-a461-442f-8a49-7eff8aea58dd.aspx</wfw:comment>
      <wfw:commentRss>http://chrison.net/SyndicationService.asmx/GetEntryCommentsRss?guid=12cc87b1-a461-442f-8a49-7eff8aea58dd</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
From the <a href="http://www.microsoft.com/uk/msdn/events/nuggets.aspx">nuggets page</a>: <em>Don't
have the time to read a 10-page how-to article or watch a full length webcast? Try
an MSDN Nugget, a webcast that takes you step-by-step to discovering new functionality
or exploring a hot developer topic, all in 10-15 minutes.</em> If you haven't seen
this yet, check it out!
</p>
        <img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=12cc87b1-a461-442f-8a49-7eff8aea58dd" />
      </body>
      <title>MSDN Nuggets</title>
      <guid isPermaLink="false">http://chrison.net/PermaLink,guid,12cc87b1-a461-442f-8a49-7eff8aea58dd.aspx</guid>
      <link>http://chrison.net/MSDNNuggets.aspx</link>
      <pubDate>Wed, 08 Nov 2006 14:04:26 GMT</pubDate>
      <description>&lt;p&gt;
From the &lt;a href="http://www.microsoft.com/uk/msdn/events/nuggets.aspx"&gt;nuggets page&lt;/a&gt;: &lt;em&gt;Don't
have the time to read a 10-page how-to article or watch a full length webcast? Try
an MSDN Nugget, a webcast that takes you step-by-step to discovering new functionality
or exploring a hot developer topic, all in 10-15 minutes.&lt;/em&gt; If you haven't seen
this yet, check it out!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=12cc87b1-a461-442f-8a49-7eff8aea58dd" /&gt;</description>
      <comments>http://chrison.net/CommentView,guid,12cc87b1-a461-442f-8a49-7eff8aea58dd.aspx</comments>
      <category>.NET</category>
      <category>ASP.NET</category>
      <category>BCL</category>
      <category>Training and Conferences</category>
    </item>
    <item>
      <trackback:ping>http://chrison.net/Trackback.aspx?guid=2727d8ad-94ac-40e0-b58f-ded31647a32e</trackback:ping>
      <pingback:server>http://chrison.net/pingback.aspx</pingback:server>
      <pingback:target>http://chrison.net/PermaLink,guid,2727d8ad-94ac-40e0-b58f-ded31647a32e.aspx</pingback:target>
      <dc:creator>Christoph Wille</dc:creator>
      <wfw:comment>http://chrison.net/CommentView,guid,2727d8ad-94ac-40e0-b58f-ded31647a32e.aspx</wfw:comment>
      <wfw:commentRss>http://chrison.net/SyndicationService.asmx/GetEntryCommentsRss?guid=2727d8ad-94ac-40e0-b58f-ded31647a32e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">A new Channel 9 wiki has popped up - about
performance tips for managed code and related CLR "stuff". A really usefull collection
of articles, videos et al - <a href="http://channel9.msdn.com/wiki/default.aspx/Channel9.RicoM">check
it out</a>!<img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=2727d8ad-94ac-40e0-b58f-ded31647a32e" /></body>
      <title>Rico Mariani's Articles and Recommendations</title>
      <guid isPermaLink="false">http://chrison.net/PermaLink,guid,2727d8ad-94ac-40e0-b58f-ded31647a32e.aspx</guid>
      <link>http://chrison.net/RicoMarianisArticlesAndRecommendations.aspx</link>
      <pubDate>Wed, 09 Mar 2005 16:03:33 GMT</pubDate>
      <description>A new Channel 9 wiki has popped up - about performance tips for managed code and related CLR "stuff". A really usefull collection of articles, videos et al - &lt;a href="http://channel9.msdn.com/wiki/default.aspx/Channel9.RicoM"&gt;check
it out&lt;/a&gt;!&lt;img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=2727d8ad-94ac-40e0-b58f-ded31647a32e" /&gt;</description>
      <comments>http://chrison.net/CommentView,guid,2727d8ad-94ac-40e0-b58f-ded31647a32e.aspx</comments>
      <category>.NET</category>
      <category>BCL</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://chrison.net/Trackback.aspx?guid=8d015084-3fda-408e-bbae-8c07f5f90773</trackback:ping>
      <pingback:server>http://chrison.net/pingback.aspx</pingback:server>
      <pingback:target>http://chrison.net/PermaLink,guid,8d015084-3fda-408e-bbae-8c07f5f90773.aspx</pingback:target>
      <dc:creator>Christoph Wille</dc:creator>
      <wfw:comment>http://chrison.net/CommentView,guid,8d015084-3fda-408e-bbae-8c07f5f90773.aspx</wfw:comment>
      <wfw:commentRss>http://chrison.net/SyndicationService.asmx/GetEntryCommentsRss?guid=8d015084-3fda-408e-bbae-8c07f5f90773</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The <a href="http://blogs.msdn.com/bclteam/">BCL Team</a> has an interesting blog
post for all those of you who want to solve every string matching problem using a
regular expression. Kit George reflects on <a href="http://blogs.msdn.com/bclteam/archive/2005/02/21/377575.aspx">when
not to use RegEx to match strings</a>.
</p>
        <img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=8d015084-3fda-408e-bbae-8c07f5f90773" />
      </body>
      <title>When not to use RegEx to match strings</title>
      <guid isPermaLink="false">http://chrison.net/PermaLink,guid,8d015084-3fda-408e-bbae-8c07f5f90773.aspx</guid>
      <link>http://chrison.net/WhenNotToUseRegExToMatchStrings.aspx</link>
      <pubDate>Tue, 22 Feb 2005 01:12:03 GMT</pubDate>
      <description>&lt;p&gt;
The &lt;a href="http://blogs.msdn.com/bclteam/"&gt;BCL Team&lt;/a&gt; has an interesting blog
post for all those of you who want to solve every string matching problem using a
regular expression. Kit George reflects on &lt;a href="http://blogs.msdn.com/bclteam/archive/2005/02/21/377575.aspx"&gt;when
not to use RegEx to match strings&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=8d015084-3fda-408e-bbae-8c07f5f90773" /&gt;</description>
      <comments>http://chrison.net/CommentView,guid,8d015084-3fda-408e-bbae-8c07f5f90773.aspx</comments>
      <category>.NET</category>
      <category>BCL</category>
    </item>
    <item>
      <trackback:ping>http://chrison.net/Trackback.aspx?guid=3b2a30cf-8697-4d57-87be-f785f29e2b05</trackback:ping>
      <pingback:server>http://chrison.net/pingback.aspx</pingback:server>
      <pingback:target>http://chrison.net/PermaLink,guid,3b2a30cf-8697-4d57-87be-f785f29e2b05.aspx</pingback:target>
      <dc:creator>Christoph Wille</dc:creator>
      <wfw:comment>http://chrison.net/CommentView,guid,3b2a30cf-8697-4d57-87be-f785f29e2b05.aspx</wfw:comment>
      <wfw:commentRss>http://chrison.net/SyndicationService.asmx/GetEntryCommentsRss?guid=3b2a30cf-8697-4d57-87be-f785f29e2b05</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Continuing in the “What’s cool in 2.0” series, I’ll look at
a BCL feature today. Imagine you have a Web form, and one of the values a user has
to enter is a double. The not-so-ingenious version to accomplish the task is as follows:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> Button1_Click(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> sender,
EventArgs e)<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> val <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> TextBox1.Text;<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//
I'm sure: it is a double</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">double</span> d <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Double.Parse(val);<br />
}</span>
        </p>
        <p>
What’s wrong? Well, there are several things that could make your application
go south, err, throw an exception: the value is null, the value is not a double, the
value is out of range for a double (all three conditions are well-documented). So
you rewrite your application like this:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">double</span> d <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0.0f;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">try</span><br />
{<br />
d <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Double.Parse(val);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">catch</span> (ArgumentNullException
ane)<br />
{<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">catch</span> (FormatException
fe)<br />
{<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">catch</span> (OverflowException
oe)<br />
{<br />
}</span>
        </p>
        <p>
This is how you would do it in 1.1, unless you first do a sanity check using regular
expressions (remember: all input is evil until proven otherwise). So what is wrong
here? The point is the exception throwing / catching in itself – it involves
a stack walk, which equates to lost performance (especially nasty when we are talking
heavy-load Web applications). Wouldn’t it be nice if we could get away without
exceptions?
</p>
        <p>
Good news! The BCL data types sport a new method – <a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdoubleclasstryparsetopic.asp">TryParse</a>.
Like the <a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdoubleclassparsetopic.asp">Parse</a> method,
it takes the input string as the first parameter. The input is followed by an out
parameter, which was the return value of Parse – the return value of TryParse
is a simple boolean: did the conversion succeed or did it fail. No exceptions. 
</p>
        <p>
The following code snippet shows how easy this is:
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">double</span> d <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0.0f;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span> (!Double.TryParse(val, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">out</span> d))<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//
handle error condition</span><br />
}</span>
        </p>
        <p>
My advice: when porting 1.1 applications to 2.0, make sure that you convert all old
Parse code to the new TryParse – your applications will perform and scale a
lot better.
</p>
        <img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=3b2a30cf-8697-4d57-87be-f785f29e2b05" />
      </body>
      <title>Parsing or: How I Learned to Stop Worrying and Love TryParse</title>
      <guid isPermaLink="false">http://chrison.net/PermaLink,guid,3b2a30cf-8697-4d57-87be-f785f29e2b05.aspx</guid>
      <link>http://chrison.net/ParsingOrHowILearnedToStopWorryingAndLoveTryParse.aspx</link>
      <pubDate>Tue, 27 Jul 2004 05:47:44 GMT</pubDate>
      <description>&lt;p&gt;
Continuing in the &amp;#8220;What&amp;#8217;s cool in 2.0&amp;#8221; series, I&amp;#8217;ll look at
a BCL feature today. Imagine you have a Web form, and one of the values a user has
to enter is a double. The not-so-ingenious version to accomplish the task is as follows:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArgs e)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; val &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; TextBox1.Text;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
I'm sure: it is a double&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;double&lt;/span&gt; d &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Double.Parse(val);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
What&amp;#8217;s wrong? Well, there are several things that could make your application
go south, err, throw an exception: the value is null, the value is not a double, the
value is out of range for a double (all three conditions are well-documented). So
you rewrite your application like this:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;double&lt;/span&gt; d &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0.0f;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;try&lt;/span&gt;
&lt;br&gt;
{&lt;br&gt;
d &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Double.Parse(val);&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;catch&lt;/span&gt; (ArgumentNullException
ane)&lt;br&gt;
{&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;catch&lt;/span&gt; (FormatException
fe)&lt;br&gt;
{&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;catch&lt;/span&gt; (OverflowException
oe)&lt;br&gt;
{&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
This is how you would do it in 1.1, unless you first do a sanity check using regular
expressions (remember: all input is evil until proven otherwise). So what is wrong
here? The point is the exception throwing / catching in itself &amp;#8211; it involves
a stack walk, which equates to lost performance (especially nasty when we are talking
heavy-load Web applications). Wouldn&amp;#8217;t it be nice if we could get away without
exceptions?
&lt;/p&gt;
&lt;p&gt;
Good news! The BCL data types sport a new method &amp;#8211; &lt;a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdoubleclasstryparsetopic.asp"&gt;TryParse&lt;/a&gt;.
Like the &lt;a href="http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdoubleclassparsetopic.asp"&gt;Parse&lt;/a&gt; method,
it takes the input string as the first parameter. The input is followed by an out
parameter, which was the return value of Parse &amp;#8211; the return value of TryParse
is a simple boolean: did the conversion succeed or did it fail. No exceptions. 
&lt;/p&gt;
&lt;p&gt;
The following code snippet shows how easy this is:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;double&lt;/span&gt; d &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0.0f;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt; (!Double.TryParse(val, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;out&lt;/span&gt; d))&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
handle error condition&lt;/span&gt;
&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
My advice: when porting 1.1 applications to 2.0, make sure that you convert all old
Parse code to the new TryParse &amp;#8211; your applications will perform and scale a
lot better.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://chrison.net/aggbug.ashx?id=3b2a30cf-8697-4d57-87be-f785f29e2b05" /&gt;</description>
      <comments>http://chrison.net/CommentView,guid,3b2a30cf-8697-4d57-87be-f785f29e2b05.aspx</comments>
      <category>2 Ohhhh</category>
      <category>BCL</category>
    </item>
  </channel>
</rss>