<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/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>.NET</title>
        <link>http://blogs.dotnetnerds.com/steve/category/78.aspx</link>
        <description>.NET</description>
        <language>en-US</language>
        <copyright>Steve Majewski</copyright>
        <managingEditor>blog@dotnetnerds.com</managingEditor>
        <generator>Subtext Version 1.9.2.23</generator>
        <item>
            <title>MCSD.NET...Finally!</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2007/07/31/MCSD.NET.Finally.aspx</link>
            <description>&lt;p&gt;After a tragic lapse in testing, I finally managed to finish off my MCSD.NET certification today. I, like so many before me, got bit by the 70-300 bug. My first attempt at the test back in February sent me home with tears and a grade just not good enough to call me certified. I rolled onto a project shortly thereafter, and the steam went out of the study engine.&lt;/p&gt; &lt;p&gt;After some soul searching and recommendations from colleagues, I picked up the &lt;a title="MCSD Analyzing Requirements and Defining .NET Solution Architectures Exam Cram 2" href="http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?z=y&amp;amp;EAN=9780789729293&amp;amp;itm=6"&gt;Exam Cram&lt;/a&gt; book from Que. I was a bit forlorn when I picked up the book last Friday. Every tech person in Denver knows about &lt;a title="SoftPro Books" href="http://softpro.stores.yahoo.net/"&gt;SoftPro Books&lt;/a&gt;. It's THE place to go for tech books when you don't have time to wait. I slap the book on the counter and the attendant gives me a half hearted, "finishing up that old certification, huh?" How rude! I knew I was running a little behind, but OLD!!!??? To pour salt on the wounds, I discovered SoftPro even removed the book from their website when I tried to link to it above. Tears of unfathomable sadness. In any case, the book along with the Transcender exams helped flesh out (and in many cases degrade) my knowledge so that I could pass the exam.&lt;/p&gt; &lt;p&gt;So while this is a happy day that I can kick the dust of the old certs off my boots and look ahead to the new (or I should say newer) stuff, I still can't help but feel like it was all for naught. I like to think I walked away with some knowledge gained, but in the end I feel like I just crammed for each test just enough so I could pass it. Well, on to the MCPD upgrade exams! Hopefully I'll complete them before someone calls me grandpa.&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:055129a0-a559-4b47-9426-393db1f0c09f" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/MCSD" rel="tag"&gt;MCSD&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/37829.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2007/07/31/MCSD.NET.Finally.aspx</guid>
            <pubDate>Wed, 01 Aug 2007 03:44:06 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/37829.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2007/07/31/MCSD.NET.Finally.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/37829.aspx</wfw:commentRss>
        </item>
        <item>
            <title>DataGridView Reentrant Call Nightmare</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2007/05/17/DataGridView-Reentrant-Call-Nightmare.aspx</link>
            <description>&lt;p&gt;The story begins with the QA team finding a bug. The description of the bug appears quite simple. When the user clicked on a cell in a &lt;code&gt;DataGridView&lt;/code&gt; on the form then closed the form using the X, reopening the form would throw an unhandled exception. "No problem," I think to myself. Little did I know the adventure on which I was about to embark.&lt;/p&gt; &lt;p&gt;Naturally, my first stop at debugging was to get the actual error that occurred. I place it here in the hopes that the wary developer scouring the web for a solution to a particularly nasty bug (get on with it) will find it and be saved:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;System.InvalidOperationException was unhandled&lt;br /&gt;Message="Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function."&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;The error message appeared simple enough. It even contained pretty words that make it much easier when finding solutions on Google (ahem...I mean MSN Search). Sadly, my search yielded me annoying solutions with no results.&lt;/p&gt; &lt;p&gt;Let me start (you're starting now?) by explaining what is happening. When the X button is hit, the form's focus does not change from the DataGridView. As a result, the grid remains in an unedited state. This particular form was being reused as a dialog, so the next time the form opened and code tried to change the grid's data, the error would occur.&lt;/p&gt; &lt;p&gt;The error is caused by an infinite loop. The cell on the grid is trying to change, thus calling the &lt;code&gt;SetCurrentCellAddressCore&lt;/code&gt;, which in turn raises some other event that calls the &lt;code&gt;SetCurrentCellAddressCore&lt;/code&gt; and so on and so forth. .NET detects the loops and gracefully crashes headlong into the ground like an ogre on ice skates.&lt;/p&gt; &lt;p&gt;The craziest part was the error would only occur when the application was run directly. When I ran it through VS in debug mode, it would continue on its merry way like nothing happened. Wrapping the offending call in a &lt;code&gt;TRY...CATCH&lt;/code&gt; block also did not work. The interactive debugger would catch the exception but running the application direct (off the same compile, mind you) would throw the error every time despite the &lt;code&gt;TRY...CATCH&lt;/code&gt;.&lt;/p&gt; &lt;p&gt;One solution I found involved deriving my own &lt;code&gt;DataGridView&lt;/code&gt; class and overriding the &lt;code&gt;SetCurrentCellAddressCore&lt;/code&gt; method. A property was added the would indicate whether or not the form was reloading data and prevent the reentrant call. While this worked for me when setting the grid's &lt;code&gt;DataSource&lt;/code&gt; to null, it caused an &lt;code&gt;IndexOutOfRangeException&lt;/code&gt; when I tried setting the DataSource later.&lt;/p&gt; &lt;p&gt;During my debugging, I could see good and well that the grid thought it was being edited thanks to the &lt;code&gt;IsCurrentCellInEditMode&lt;/code&gt; property. I tried calling the &lt;code&gt;CancelEdit&lt;/code&gt;, &lt;code&gt;EndEdit&lt;/code&gt;, and even &lt;code&gt;NotifyCurrentCellDirty&lt;/code&gt; methods, but the grid remained in edit mode. I tried directly setting the &lt;code&gt;CurrentCell&lt;/code&gt; to null. No dice. The grid refused to realize that it really wasn't being edited.&lt;/p&gt; &lt;p&gt;Finally, light dawned on marble head. The problem is the grid is still active when the form is closed. What if I just selected another control when closing the form? There was no reason not to set the focus back to the first control on the form so that the next time the form opened it would be selected. &lt;/p&gt; &lt;p&gt;Even though I had code in place to switch the control focus, it was triggered when the form was opened (activated really) rather than when it was closed. The only thing I can deduce is the grid goes into a strange limbo if the form is closed whilst it is in edit mode. I created a &lt;code&gt;FormClosing&lt;/code&gt; event and added the one line of code to select the first control on the form. That was enough to switch the grid out of edit mode so that it could be manipulated the next time the form was opened.&lt;/p&gt; &lt;p&gt;So what started as an easy looking bug ended with an easy solution with about 10 hours of hair pulling antics piled up in the middle. Either way, I still got the warm fuzzies when I saw it work. That is the mark of a true developer.&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:651e31c5-4c68-4d1a-8f8c-f160d934a27a" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;, &lt;a href="http://technorati.com/tags/DataGridView" rel="tag"&gt;DataGridView&lt;/a&gt;, &lt;a href="http://technorati.com/tags/WinForms" rel="tag"&gt;WinForms&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/37825.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2007/05/17/DataGridView-Reentrant-Call-Nightmare.aspx</guid>
            <pubDate>Thu, 17 May 2007 15:01:47 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/37825.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2007/05/17/DataGridView-Reentrant-Call-Nightmare.aspx#feedback</comments>
            <slash:comments>26</slash:comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/37825.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Implementing List.Find in .NET 2.0</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2007/04/24/Implementing-List.Find-in-.NET-2.0.aspx</link>
            <description>&lt;p&gt;&lt;/p&gt; &lt;p&gt;I'm putting this here more as a reminder to myself than anything else because I'm tired of looking it up every time I need to implement one of these things (of course, isn't that why people write blogs?).  &lt;/p&gt;&lt;p&gt;The List generic class added in .NET 2.0 (&lt;a title="MSDN - List Generic Class" href="http://msdn2.microsoft.com/en-us/library/6sh2ey19.aspx" target="_blank"&gt;System.Collections.Generic.List&lt;t&gt;&lt;/t&gt;&lt;/a&gt;) is probably my most favorite addition to .NET 2.0 (well, generics in general). No longer do I have waste time creating a custom collection class just to get a strongly typed collection for my business objects. It even has the ability to do searching against the list provided you can get past Microsoft's less-than-informative help.  &lt;/p&gt;&lt;p&gt;The List class has a Contains method, which will search the list for an instance of a given object. However, that will only indicate whether or not the list contains the same instance of the object. So having another object with the same data will yield a false negative when using the Contains method (if duplicate data is not the desired result, of course).  &lt;/p&gt;&lt;p&gt;The Find method is more flexible because it allows the developer to define how to compare the objects. To perform a Find on a generic list, you need to create a &lt;a title="MSDN - Predicate Generic Delegate (System)" href="http://msdn2.microsoft.com/en-us/library/bfcke1bz.aspx" target="_blank"&gt;Predicate&lt;/a&gt; to do the legwork. A Predicate is nothing more than a generic delegate that defines criteria and determines whether or not the criteria are met.  &lt;/p&gt;&lt;p&gt;There are several ways to define a Predicate, but this is the method I prefer to use because I creates clean, reusable code:&lt;/p&gt;&lt;pre&gt;public class Person
{
    public string LastName;
    public string FirstName;

    public static Predicate&amp;lt;Person&amp;gt;&lt;person&gt; FindPredicate(Person person1)
    {
        return delegate(Person person2)
        {
            return person1.LastName == person2.LastName
                &amp;amp;&amp;amp; person1.FirstName == person2.FirstName;
        };
    }

    public static Predicate&amp;lt;Person&amp;gt;&lt;person&gt; FindByLastNamePredicate(string lastName)
    {
        return delegate(Person person)
        {
            return person.LastName == lastName;
        };
    }
}

&lt;/person&gt;&lt;/person&gt;&lt;/pre&gt;
&lt;p&gt;Here I've defined two different (if not very simplistic) Predicate functions. The Predicate function creates an inline delegate that receives a Person datatype. The Find method will always pass in an object of the List's datatype, so there is no flexibility on the method signature for the delegate. However, the data passed into the Predicate method can be anything, and the variables are available in the delegate's code block. This allows for comparison logic to be as complex as needed. Keep in mind that the Find method will only return the first item in the list that matches the criteria.&lt;/p&gt;
&lt;p&gt;To use the predicate, the code would look something like this:&lt;/p&gt;&lt;pre&gt;// add person if not already in the list
if (myPeeps.Find(Person.FindPredicate(peepToFind)) == null)
{
    myPeeps.Add(peepToFind);
}

// find first person with a last name of Gump
Person foundPeep = myPeeps.Find(Person.FindByLastNamePredicate("Gump"));

&lt;/pre&gt;
&lt;p&gt;Of course, Predicate methods could be defined anywhere. It makes sense (to me anyway) to put them on the business object as a static method, since it doesn't hurt for a business object to know how to compare itself to given criteria. &lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:2ac3474f-4e50-4d38-87d4-704886931daa" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati tags: &lt;a href="http://technorati.com/tags/.NET" rel="tag"&gt;.NET&lt;/a&gt;, &lt;a href="http://technorati.com/tags/C#" rel="tag"&gt;C#&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Generics" rel="tag"&gt;Generics&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/37824.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2007/04/24/Implementing-List.Find-in-.NET-2.0.aspx</guid>
            <pubDate>Wed, 25 Apr 2007 04:00:33 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/37824.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2007/04/24/Implementing-List.Find-in-.NET-2.0.aspx#feedback</comments>
            <slash:comments>5</slash:comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/37824.aspx</wfw:commentRss>
        </item>
        <item>
            <title>LCD Life</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2006/10/05/LCD-Life.aspx</link>
            <description>&lt;img width="200" height="296" align="right" style="padding-left: 10px;" alt="LCD Life" src="/images/blogs_dotnetnerds_com/steve/49/o_LcdLife.gif" /&gt;
&lt;p&gt;I finished my first little app for my &lt;a href="http://blogs.dotnetnerds.com/steve/archive/2006/10/03/New-Toys.aspx"&gt;G15&lt;/a&gt;, LCD Life. It’s your standard life simulator, where you control the criteria by which life will survive or perish. My goal was to learn the ins and outs of the keyboard. The end result was a bit more over the top.  &lt;/p&gt;
&lt;p&gt;I’m not going to bother discussing how it works, because it’s pretty straight forward. If nothing more, it makes for an interesting screen saver.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;Soft Keys&lt;/h3&gt;
&lt;ol&gt;
    &lt;li&gt;Decrease speed&lt;br /&gt;
    &lt;/li&gt;
    &lt;li&gt;Increase speed&lt;/li&gt;
    &lt;li&gt;Start&lt;/li&gt;
    &lt;li&gt;Stop &lt;br /&gt;
    &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h3&gt;Download&lt;/h3&gt;
&lt;ul&gt;
    &lt;li&gt;&lt;a href="../../../../files/lgLcdLife.zip"&gt;Executable&lt;/a&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href="../../../../files/lgLcdLife_Source.zip"&gt;Source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I'm too lazy to create an installation package for this thing, so please note that it requires .NET 1.1 Framework (naturally). I am in no way responsible if it gets loose and eats your keyboard.&lt;/p&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/37579.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2006/10/05/LCD-Life.aspx</guid>
            <pubDate>Thu, 05 Oct 2006 21:59:39 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/37579.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2006/10/05/LCD-Life.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/37579.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Subtext Links Bug</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2006/10/02/Subtext-Links-Bug.aspx</link>
            <description>There is a bug in the current version of Subtext that causes the links to not appear. Luckily my wife found &lt;a href="https://sourceforge.net/tracker/index.php?func=detail&amp;amp;aid=1552290&amp;amp;group_id=137896&amp;amp;atid=739979" target="_blank"&gt;this&lt;/a&gt; bug discussing the issue. To sumarize, this is the code you need to run against you Subtext database to get everything cleaned up: 
&lt;pre&gt;UPDATE subtext_LinkCategories SET CategoryType = 5 WHERE&lt;br /&gt;CategoryType = 0&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;-- The stored proc change&lt;br /&gt;ALTER PROC&lt;br /&gt;[dbo].[subtext_GetActiveCategoriesWithLinkCollection]&lt;br /&gt;(&lt;br /&gt;    @BlogId int = NULL&lt;br /&gt;)&lt;br /&gt;AS&lt;br /&gt;SELECT subtext_LinkCategories.CategoryID&lt;br /&gt;    , subtext_LinkCategories.Title&lt;br /&gt;    , subtext_LinkCategories.Active&lt;br /&gt;    , subtext_LinkCategories.CategoryType&lt;br /&gt;    , subtext_LinkCategories.[Description]&lt;br /&gt;FROM [dbo].[subtext_LinkCategories]&lt;br /&gt;WHERE   &lt;br /&gt;            subtext_LinkCategories.Active= 1&lt;br /&gt;    AND        (subtext_LinkCategories.BlogId = @BlogId OR @BlogId IS&lt;br /&gt;NULL)&lt;br /&gt;    AND        subtext_LinkCategories.CategoryType = 5&lt;br /&gt;ORDER BY&lt;br /&gt;    subtext_LinkCategories.Title;&lt;br /&gt;&lt;br /&gt;SELECT links.LinkID&lt;br /&gt;    , links.Title&lt;br /&gt;    , links.Url&lt;br /&gt;    , links.Rss&lt;br /&gt;    , links.Active&lt;br /&gt;    , links.NewWindow&lt;br /&gt;    , links.CategoryID&lt;br /&gt;    , PostID = ISNULL(links.PostID, -1)&lt;br /&gt;FROM [dbo].[subtext_Links] links&lt;br /&gt;    INNER JOIN [dbo].[subtext_LinkCategories] categories ON&lt;br /&gt;links.CategoryID = categories.CategoryID&lt;br /&gt;WHERE&lt;br /&gt;        links.Active = 1&lt;br /&gt;    AND categories.Active = 1&lt;br /&gt;    AND (categories.BlogId = @BlogId OR @BlogId IS NULL)&lt;br /&gt;    AND links.BlogId = @BlogId&lt;br /&gt;    AND categories.CategoryType = 5&lt;br /&gt;ORDER BY&lt;br /&gt;    links.Title;&lt;br /&gt;&lt;/pre&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/37566.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2006/10/02/Subtext-Links-Bug.aspx</guid>
            <pubDate>Mon, 02 Oct 2006 21:53:48 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/37566.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2006/10/02/Subtext-Links-Bug.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/37566.aspx</wfw:commentRss>
        </item>
        <item>
            <title>MCAD.NET</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2006/08/08/36932.aspx</link>
            <description>&lt;p&gt;
Last Friday, I completed my third Microsoft Certification Exam, 70-320. It was the final test in obtaining my MCAD.NET certification. From there, I have two more exams to complete my MCSD.NET. Then I’ll have two upgrade exams for the new exams for .NET 2.0.
&lt;/p&gt;
&lt;p&gt;
Back to the test last Friday, I found the &lt;a href="http://www.transcender.com"&gt;Transcender&lt;/a&gt; exams to be somewhat lacking in preparing me for the exam. The test centers around XML web services and server components. The Transcender focuses on a broader range of topics, including ones covered in 70-315 and 70-316. Since I don’t use the technologies covered in 70-320 often, I had to rely on the Transcender to give me a better idea of what to study. 
&lt;/p&gt;
&lt;p&gt;
I was in a bit of a hurry to complete the test and did not have the time to complete the most excellent &lt;a href="http://softpro.stores.yahoo.net/0-7897-2824-9.html"&gt;Training guide from the Kalani’s&lt;/a&gt;. Luckily, I was able to review the Fast Facts section of the book. Without it and my previous experience with the technologies, I probably would have failed the test.
&lt;/p&gt;
&lt;p&gt;
I’ve heard mixed reviews of the 70-320 test. Some have said it was identical to the Transcender while others, like me, have said the Transcender fell far short. I can only assume it’s the luck of the draw as to which test you get, but it seems to me that there are varying levels of test difficulty.
&lt;/p&gt;
&lt;p&gt;
If your company supplies Transcender tests for you, then by all means use them. But if you’re paying for them on your own (or with a limited expense account), I think you’ll be better off with the Kalani Training Guide. It contains a sample test as well as software with sample questions and does a much better job at prepping you for the test.
&lt;/p&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/36932.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Stephen Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2006/08/08/36932.aspx</guid>
            <pubDate>Wed, 09 Aug 2006 04:20:00 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/36932.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2006/08/08/36932.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/36932.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Testing if a String is Numeric in C#</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2006/05/31/34289.aspx</link>
            <description>&lt;p&gt;Though it may not be obvious, there is a quick and easy way in C# (or any of the .NET languages) to test if a string value is numeric. The most common solutions I've encountered involve testing each character in the string with &lt;code&gt;Char.IsNumeric&lt;/code&gt; or wrapping a specific parse call (such as &lt;code&gt;int.Parse&lt;/code&gt;) within a &lt;code&gt;Try...Catch&lt;/code&gt; block. I've also seen regular expressions used as a creative alternative. While all these methods work, there is a much easier, efficient, and flexible way to test a string: &lt;code&gt;Double.TryParse&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Per the .NET documentation:&lt;/p&gt;

&lt;blockquote&gt;The TryParse method is like the Parse method, except this method does not throw an exception if the conversion fails. If the conversion succeeds, the return value is true and the result parameter is set to the outcome of the conversion. If the conversion fails, the return value is false and the result parameter is set to zero.&lt;/blockquote&gt;

&lt;p&gt;The parameters received by the TryParse method allow for a wide variety of number styles as well as cuture specific parsing. Here's an example:&lt;/p&gt;

&lt;pre&gt;
Double value;
bool result = Double.TryParse(
    givenString, 
    NumberStyles.None, 
    CultureInfo.CurrentCulture, 
    out value);
&lt;/pre&gt;

&lt;p&gt;This example will try to parse the &lt;code&gt;givenString&lt;/code&gt; variable as a positive integer with no additional formatting (such as thousands separators) using the current cuture of my machine. No &lt;code&gt;Try...Catch&lt;/code&gt; needed. No sluggish loop.&lt;/p&gt;

&lt;p&gt;Changing the &lt;code&gt;NumberStyles&lt;/code&gt; enumeration lets me define the allowed style of the number. I can be as limiting as a positive integer or as flexible as exponential notation. The enumeration is also bitwise, meaning multiple values can be combined. For example:&lt;/p&gt;

&lt;pre&gt;
bool result = Double.TryParse(
    givenString, 
    NumberStyles.AllowLeadingSign | 
    NumberStyles.AllowDecimalPoint, 
    CultureInfo.CurrentCulture, 
    out value);
&lt;/pre&gt;

&lt;p&gt;This example will try to parse the &lt;code&gt;givenString&lt;/code&gt; variable as a positive or negative decimal value with no additional formatting (such as thousands separators) using the current cuture of my machine. I've yet to see a custom method with that level of flexbility.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;CultureInfo&lt;/code&gt; defines the allowed symbols (such as currency) and the overall number formatting. This is a major shortcoming of many of the custom methods I've seen. Coding with globalization in mind is important for a developer, regardless of where the app is being used.&lt;/p&gt;

&lt;p&gt;See the VS help for &lt;code&gt;System.Double.TryParse&lt;/code&gt; and &lt;code&gt;System.Globalization.NumberStyles&lt;/code&gt; for more details.&lt;/p&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/34289.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Stephen Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2006/05/31/34289.aspx</guid>
            <pubDate>Wed, 31 May 2006 21:43:00 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/34289.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2006/05/31/34289.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/34289.aspx</wfw:commentRss>
        </item>
        <item>
            <title>MCSD Step One (70-315)</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2006/01/16/30498.aspx</link>
            <description>&lt;p&gt;Hello there. I know I've been slacking, but I'm between projects right now and putting major focus on finally tackling my MCSD certification. At Avanade, solutions developers are required to get MCSD certified within their first year of employment (lower level developers are only required to get their MCAD). After over 6 months of fiddling around, I finally took on my first exam, 70-315.&lt;/p&gt;

&lt;p&gt;Through Avanade, I'm supplied a number of resources for studying for the exam. As expected, &lt;a href="http://www.transcender.com/default.aspx"&gt;Transcender&lt;/a&gt; Exams became my best friends. However, another excellent resource I had prior to coming to Avanade was &lt;a href="http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=WM05gXuCXi&amp;amp;isbn=0789728222&amp;amp;itm=4"&gt;Amit Kalani's&lt;/a&gt; book. Personally, I think Kalani is the best when it comes to exam prep guides.&lt;/p&gt;

&lt;p&gt;Since I've been doing .NET development for a few years now, I didn't feel the need to go through the book cover to cover. I used the Transcender exams to identify my weaknesses, then Kalani's book to strengthen them. Finally, I took the sample exam in Kalani's book to identify any remaining weaknesses. Oddly enough, I ended up scoring better on my original weak areas than I did on my strong areas. Such is life.&lt;/p&gt;

&lt;p&gt;The exam itself followed the flow of the sample tests. Some the questions were obviously designed to trick, so it helps to really read the questions multiple times. With roughly 2 hours for 43 questions, I had plenty of time. I walked away with a 924 and one exam under my belt. Sure, I could add MCP to my name now, but that would just be lame.&lt;/p&gt;

&lt;p&gt;In the next few days I'm tackling 70-316, since it shares many of the objectives of 70-315. Then it's on to 70-320 to close out my MCAD. From the sounds of things from colleagues, Transcenders alone will not help with this exam. Also, the books offered by Microsoft Press are lacking in all the topics covered by the exam. Again, I plan to grab Kalani's book and study away.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; Despite the proliferation of Transcender exams, Microsoft has yet to update the Office spelling dictionary to include the word. As such, it wants to replace my "misspelling" with the word "transgender." -- END OF LINE&lt;/p&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/30498.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2006/01/16/30498.aspx</guid>
            <pubDate>Tue, 17 Jan 2006 05:57:00 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/30498.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2006/01/16/30498.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/30498.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Moving Items Between ListBox Objects</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2005/11/08/26523.aspx</link>
            <description>&lt;p&gt;A friend recently asked me a question regarding moving selected items between two list boxes. This had to occur on the backend, because all good developers know relying on JavaScript alone is bad form.&lt;/p&gt;

&lt;p&gt;Whenever he tried to remove the item while looping over the list, he would receive an enumeration error. Here’s what he was doing:&lt;/p&gt;

&lt;pre class="normal"&gt;for each ( ListBoxItem item in ListBox1.Items )
{
    if ( item.Selected )
    {
        ListBox2.Items.Add(item);
        ListBox1.Items.Remove(item);
    }
}&lt;/pre&gt;

&lt;p&gt;Having dealt with list box manipulation in JavaScript, I immediately recognized the problem. It is impossible to loop through a list like this and start removing items. In JavaScript, it is allowed but yields undesirable results. .NET will throw a runtime error the instant the list is modified while being looped.&lt;/p&gt;

&lt;p&gt;One work around (though other methods may exist) involves using indices to reverence the items rather than objects. Looping over the items (using a &lt;code&gt;for each&lt;/code&gt; loop) locks the list from being changed. Using the index eliminates the enumeration, thus allowing a list to be modified and looped at the same time. For example:&lt;/p&gt;

&lt;pre class="normal"&gt;for ( int i = ListBox1.Items.Count - 1; i &gt;= 0; i-- )
{
    if ( ListBox1.Items[i].Selected )
    {
        ListBox2.Items.Add(ListBox1.Items[i]);
        ListBox1.Items.RemoveAt(i);
    }
}&lt;/pre&gt;

&lt;p&gt;It is necessary to loop the list backwards so that once an item is deleted it does not throw off the index. In other words, if the loop went forwards and deleted item 3, item 4 would become item 3 and so on down the line. Therefore on the next iteration (when i=4), item 4 is now item 3 and would end up being skipped (did you get all that?). This is pretty much the same reason .NET threw the enumeration error that started this whole issue.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; Code was written off the top of my head and is not 100% guaranteed to work.&lt;/p&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/26523.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Stephen Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2005/11/08/26523.aspx</guid>
            <pubDate>Tue, 08 Nov 2005 19:19:00 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/26523.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2005/11/08/26523.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/26523.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Visual Studio 2005 and .NET Framework 2.0 Shipped!!!</title>
            <link>http://blogs.dotnetnerds.com/steve/archive/2005/10/27/25750.aspx</link>
            <description>&lt;p&gt;If you subscribe to MSDN that is. As I write this, only a few pieces have shown up. However, according to &lt;a href="http://blogs.msdn.com/somasegar/archive/2005/10/27/485665.aspx"&gt;Somasegar's blog&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;Later in the day, the final bits will be up on MSDN for our MSDN subscribers around the world to get access to the product.&lt;/blockquote&gt;

&lt;p&gt;And from &lt;a href="http://blogs.msdn.com/robcaron/archive/2005/10/27/485690.aspx"&gt;Rob Caron's blog&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;The official launch is still November 7th, but Visual Studio 2005 is available for download starting today. This includes Visual Studio 2005 Team Suite, the role-based editions, and Visual Studio 2005 Team Test Load Agent. We're also releasing a Beta 3 Refresh of Team Foundation Server (later today). Of course, the downloads are for those with the appropriate MSDN Subscription; otherwise, you'll be able to download a trial version of Visual Studio 2005 Team Suite. &lt;/blockquote&gt;

&lt;p&gt;Hat tip: &lt;a href="http://www.sellsbrothers.com/"&gt;Chris Sells&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.dotnetnerds.com/steve/aggbug/25750.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Stephen Majewski</dc:creator>
            <guid>http://blogs.dotnetnerds.com/steve/archive/2005/10/27/25750.aspx</guid>
            <pubDate>Thu, 27 Oct 2005 20:00:00 GMT</pubDate>
            <wfw:comment>http://blogs.dotnetnerds.com/steve/comments/25750.aspx</wfw:comment>
            <comments>http://blogs.dotnetnerds.com/steve/archive/2005/10/27/25750.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.dotnetnerds.com/steve/comments/commentRss/25750.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>