<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title> - Technical questions - Problem reading along in C# - Messages</title>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<description> - Technical questions - Problem reading along in C# - Messages</description>
<language>en-us</language>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<generator>Jitbit AspNetForum</generator>
<pubDate>Fri, 20 Jun 2008 23:30:10 GMT</pubDate>
<lastBuildDate>Fri, 20 Jun 2008 23:30:10 GMT</lastBuildDate>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from OnlyMaverick</title>
<description><![CDATA[Haha, apologize for the typo.<br/><br/>Cheers <img src="images/smilies/wink.gif" border=0><br/><br/><b>Ken Cox</b> wrote:<br><div class=quote><b>OnlyMaverick</b> wrote:<br><div class=quote>enClr = new System.Drawing.<u><b><i>Knowing</i></b></u>Color();<br/></div><br/><br/><b>Knowing</b>? Are you sure about that? That's one heckuva fix! <img src="images/smilies/smile.gif" border=0><br/><br/>Ken</div>]]></description>
<pubDate>Fri, 20 Jun 2008 23:30:10 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from Ken Cox</title>
<description><![CDATA[<b>OnlyMaverick</b> wrote:<br><div class=quote>enClr = new System.Drawing.<u><b><i>Knowing</i></b></u>Color();<br/></div><br/><br/><b>Knowing</b>? Are you sure about that? That's one heckuva fix! <img src="images/smilies/smile.gif" border=0><br/><br/>Ken]]></description>
<pubDate>Fri, 20 Jun 2008 22:56:28 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from OnlyMaverick</title>
<description><![CDATA[<b>wtetlow</b> wrote:<br><div class=quote>clrs.AddRange((System.Collections.Generic.IEnumerable&lt;System.Drawing.KnownColor&gt<img src="images/smilies/wink.gif" border=0>System.Enum.GetValues(enClr.GetType())); will also work. I wish I had read this thread before struggling to find an answer on my own.</div><br/><br/>Ok this makes sense but I actually got an error message saying <br/>"unassigned local variable enClr"<br/><br/>Then I had to allocate memory to the enClr = new System.Drawing.KnowingColor();<br/><br/>I wish i didn't have to allocate memory<br/><br/>Thanks again , it finally worked <img src="images/smilies/smile.gif" border=0>]]></description>
<pubDate>Fri, 20 Jun 2008 04:41:33 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from OnlyMaverick</title>
<description><![CDATA[<b>wtetlow</b> wrote:<br><div class=quote>clrs.AddRange((System.Collections.Generic.IEnumerable&lt;System.Drawing.KnownColor&gt<img src="images/smilies/wink.gif" border=0>System.Enum.GetValues(enClr.GetType())); will also work. I wish I had read this thread before struggling to find an answer on my own.</div><br/><br/>Ok this makes sense but I actually got an error message saying <br/>"unassigned local variable enClr"<br/><br/>Then I had to allocate memory to the enClr = new System.Drawing.KnowingColor();<br/><br/>I wish i didn't have to allocate memory<br/><br/>Thanks again , it finally worked <img src="images/smilies/smile.gif" border=0><br/><em>edited by OnlyMaverick on 6/20/2008</em>]]></description>
<pubDate>Fri, 20 Jun 2008 04:39:57 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from OnlyMaverick</title>
<description><![CDATA[thank you for the C# entry.<br/>is there C# code for the other pages as well?<br/><br/><b>wtetlow</b> wrote:<br><div class=quote>Here's a little shorter version to overcome the "IsDate not in C#" issue:<br/>        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)<br/>    {<br/>        DateTime x = new DateTime();<br/>        args.IsValid = DateTime.TryParse(args.Value, out x);<br/>    }<br/> <br/><b>dgraper</b> wrote:<br><div class=quote>wtetlow:<br/><br/>My copy of the book only has 404 pages so perhaps you're referencing another book's page 779?<br/><br/>Another small modification for reading along with the book in C# -- there's another VB coder at my site who's started reading this book and he got stuck on pg. 59 when he discovered the ISDATE() function isn't supported by C#.   His solution was kludgy, bringing in the MICROSOFT.SYSTEM.VBNET() library or something like that, but it seemed more elegant to just include an ISDATE() function in the code:<br/><br/>    public static bool IsDate(string strDate)<br/>    {<br/>        DateTime dtDate;<br/>        bool bValid = true;<br/>        try<br/>        {<br/>            dtDate = DateTime.Parse(strDate);<br/>        }<br/>        catch (FormatException eFormatException)<br/>        {<br/>            // the Parse method failed =&gt; the string strDate cannot be converted to a date.<br/>            bValid = false;<br/>        }<br/>        return bValid;<br/>    }<br/><br/>I can't claim credit for the function, I copied it from some newgroup posting and keep it in a class library that I include in my projects as a crutch as I transition from VB to C#.  <br/><br/>As regards other comment -- it would be nice to have a C# version of all the code available for download.  At my site we're all being forced to move over to C# and as I mentioned I've already found someone else quietly reading this book, there are probably more.   I'll tell them about this website, perhaps something can be pieced together from notes in this thread.<br/><br/>Thanks again!  - Dave</div></div>]]></description>
<pubDate>Wed, 18 Jun 2008 02:28:01 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from Ken Cox</title>
<description><![CDATA[<b>dgraper</b> wrote:<br><div class=quote>Perhaps I used the inappropriate adverb ... it seemed more apropos than "surreptitiously," though.</div><br/><br/>Like you, I have problems with the "Dummies" stigma. Of course it's easier to be seen with a Dummies book if the boss knows you're mainly competent but trying to get up to speed on the latest and greatest.<br/><br/>The title aside, it's hard to argue with success of the Dummies franchise. There's hardly a topic they don't touch. Hmmm. I don't think I've seen "Porn For Dummies" yet. <img src="images/smilies/smile.gif" border=0><br/><br/>Ken]]></description>
<pubDate>Mon, 14 Apr 2008 15:43:33 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from dgraper</title>
<description><![CDATA[Perhaps I used the inappropriate adverb ... it seemed more apropos than "surreptitiously," though.<br/><br/>If I might go off-topic for just a moment:  While I feel this is an excellent introductory book, its cover can frighten pointy-haired-boss-types who wander by our cubicles with their friends pointing out their high-paid consultants.   (That's "high-paid" only in their view -- when compared to the student interns and body-shop programmers they've come to prefer.)  The other coder I discovered reading the book was keeping it under a pile of IBM Redbooks and immediately said that he was reading it "just to get his feet wet" as if it was a porno magazine.  I too have contemplated removing the cover.<br/><br/>Perhaps it would have been wiser for me to save this information about my co-worker for potential blackmail use in the future but I admitted I too was reading it, it really stands out as a resource for developers wanting to learn ASP.NET 3.5 quickly.]]></description>
<pubDate>Sun, 13 Apr 2008 14:28:59 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from wtetlow</title>
<description><![CDATA[Here's a little shorter version to overcome the "IsDate not in C#" issue:<br/>        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)<br/>    {<br/>        DateTime x = new DateTime();<br/>        args.IsValid = DateTime.TryParse(args.Value, out x);<br/>    }<br/> <br/><b>dgraper</b> wrote:<br><div class=quote>wtetlow:<br/><br/>My copy of the book only has 404 pages so perhaps you're referencing another book's page 779?<br/><br/>Another small modification for reading along with the book in C# -- there's another VB coder at my site who's started reading this book and he got stuck on pg. 59 when he discovered the ISDATE() function isn't supported by C#.   His solution was kludgy, bringing in the MICROSOFT.SYSTEM.VBNET() library or something like that, but it seemed more elegant to just include an ISDATE() function in the code:<br/><br/>    public static bool IsDate(string strDate)<br/>    {<br/>        DateTime dtDate;<br/>        bool bValid = true;<br/>        try<br/>        {<br/>            dtDate = DateTime.Parse(strDate);<br/>        }<br/>        catch (FormatException eFormatException)<br/>        {<br/>            // the Parse method failed =&gt; the string strDate cannot be converted to a date.<br/>            bValid = false;<br/>        }<br/>        return bValid;<br/>    }<br/><br/>I can't claim credit for the function, I copied it from some newgroup posting and keep it in a class library that I include in my projects as a crutch as I transition from VB to C#.  <br/><br/>As regards other comment -- it would be nice to have a C# version of all the code available for download.  At my site we're all being forced to move over to C# and as I mentioned I've already found someone else quietly reading this book, there are probably more.   I'll tell them about this website, perhaps something can be pieced together from notes in this thread.<br/><br/>Thanks again!  - Dave</div>]]></description>
<pubDate>Sun, 13 Apr 2008 14:03:03 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from Ken Cox</title>
<description><![CDATA[<b>wtetlow</b> wrote:<br><div class=quote>someone else quietly reading this book</div><br/><br/>At least they're reading <i>quietly</i>! <br/><br/>Still, it's hard to work with someone in the next cube reading a computer book out loud. The funny parts are okay, but listening to a recitation of listings really wrecks my concentration. <br/><br/><img src="images/smilies/smile.gif" border=0>]]></description>
<pubDate>Sun, 13 Apr 2008 13:00:57 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from Ken Cox</title>
<description><![CDATA[Hi Dave,<br/><br/>Thanks for the conversion - all contributions gratefully received!<br/><br/>I did have it in mind to produce C# versions of all the listings as soon as the book was sent to the printer. Unfortunately (and fortunately!), I got very busy with a nice Web site contract and time seems to be short these days.<br/><br/>Perhaps I should create a forum where guys can post C# snippets with page references.<br/><br/>Oh, and that page reference should have been 379.  <img src="images/smilies/eek7.gif" border="0" alt="Whaaaaa?" /><br/><br/>Ken]]></description>
<pubDate>Sun, 13 Apr 2008 12:57:08 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from dgraper</title>
<description><![CDATA[wtetlow:<br/><br/>My copy of the book only has 404 pages so perhaps you're referencing another book's page 779?<br/><br/>Another small modification for reading along with the book in C# -- there's another VB coder at my site who's started reading this book and he got stuck on pg. 59 when he discovered the ISDATE() function isn't supported by C#.   His solution was kludgy, bringing in the MICROSOFT.SYSTEM.VBNET() library or something like that, but it seemed more elegant to just include an ISDATE() function in the code:<br/><br/>    public static bool IsDate(string strDate)<br/>    {<br/>        DateTime dtDate;<br/>        bool bValid = true;<br/>        try<br/>        {<br/>            dtDate = DateTime.Parse(strDate);<br/>        }<br/>        catch (FormatException eFormatException)<br/>        {<br/>            // the Parse method failed =&gt; the string strDate cannot be converted to a date.<br/>            bValid = false;<br/>        }<br/>        return bValid;<br/>    }<br/><br/>I can't claim credit for the function, I copied it from some newgroup posting and keep it in a class library that I include in my projects as a crutch as I transition from VB to C#.  <br/><br/>As regards other comment -- it would be nice to have a C# version of all the code available for download.  At my site we're all being forced to move over to C# and as I mentioned I've already found someone else quietly reading this book, there are probably more.   I'll tell them about this website, perhaps something can be pieced together from notes in this thread.<br/><br/>Thanks again!  - Dave]]></description>
<pubDate>Sun, 13 Apr 2008 12:48:21 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from Ken Cox</title>
<description><![CDATA[<b>wtetlow</b> wrote:<br><div class=quote>clrs.AddRange((System.Collections.Generic.IEnumerable&lt;System.Drawing.KnownColor&gt<img src="images/smilies/wink.gif" border=0>System.Enum.GetValues(enClr.GetType())); will also work. I wish I had read this thread before struggling to find an answer on my own.</div><br/><br/>I hear you! See Page 779, "Stop Bashing Your Head against a Wall" <img src="images/smilies/smile.gif" border=0><br/><br/>My trick in the past has been to take my VB code, compile it and look at the decompiled version as C# using <A href="http://www.aisto.com/roeder/dotnet" target="_blank" rel="nofollow">Reflector</a>!]]></description>
<pubDate>Fri, 11 Apr 2008 21:23:46 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from wtetlow</title>
<description><![CDATA[clrs.AddRange((System.Collections.Generic.IEnumerable&lt;System.Drawing.KnownColor&gt<img src="images/smilies/wink.gif" border=0>System.Enum.GetValues(enClr.GetType())); will also work. I wish I had read this thread before struggling to find an answer on my own.]]></description>
<pubDate>Fri, 11 Apr 2008 18:29:35 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from Ken Cox</title>
<description><![CDATA[Hi Dave,<br/><br/>Glad to see you found an answer, and thanks for providing it here! <img src="images/smilies/smile.gif" border=0><br/><br/>Like you, I'm a VB guy who is working in C# on projects. Most of the time IntelliSense gets me through the syntax and case-sensitive nonsense. However, I wouldn't have known where to start with that enum thingy.<br/><br/>Oh, and once you get all the book's code translated from VB to C#, you're welcome to pass it along. <img src="images/smilies/wink.gif" border=0><br/><br/>Ken]]></description>
<pubDate>Mon, 07 Apr 2008 10:45:21 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from dgraper</title>
<description><![CDATA[Here's the single line answer (given to me by Martin Honnen, XML MVP):<br/><br/>clrs.AddRange(System.Enum.GetValues(typeof(System.Drawing.KnownColor)).Cast&lt;System.Drawing.KnownColor&gt;()); <br/><br/>I was sort-of on the right track.  This casting feature is unique to NET3.5, he said (complete post in the <i>Microsoft.Public.DotNet.Languages.CSharp</i> newgroup).  <br/><br/>I'm coming from a NET2.0 background so this was new to me, that's what threw me.]]></description>
<pubDate>Mon, 07 Apr 2008 10:03:46 GMT</pubDate>
</item>
<item>
<link>http://www.kencox.ca/forum/messages.aspx?TopicID=14</link>
<title>Message from dgraper</title>
<description><![CDATA[Greetings.<br/><br/>Thanks for the book ... I need a quick overview of this topic and this book absolutely fits the bill.<br/><br/>I'm an ex-VB coder with a new job in an all-C# shop and am going thru the book translating the examples into C#.   So far only one problem, pg. 70:<br/><br/>     Dim enClr As System.Drawing.KnownColor<br/>     Dim clrs As New System.Collections.Generic.List (Of System.Drawing.KnownColor)<br/>     clrs.AddRange(System.Enum.GetValues (enClr.GetType()))<br/><br/>This seemed like an easy translation into C#:<br/><br/>            System.Drawing.KnownColor enClr;<br/>            System.Collections.Generic.List&lt;System.Drawing.KnownColor&gt; clrs = new<br/>                System.Collections.Generic.List&lt;System.Drawing.KnownColor&gt;();<br/>            clrs.AddRange(System.Enum.GetValues(enClr.GetType()));<br/><br/>But I can't seem to get past an error in line 3 ("clrs.AddRange..."):<br/><br/>     "Argument '1': cannot convert from 'System.Array' <br/>              to 'System.Collections.Generic.IEnumerable&lt;System.Drawing.KnownColor&gt;'	<br/><br/>It would seem that System.Enum.GetValues(enClr.GetType())) <i>is </i>returning a generic list of color objects but the AddRange method isn't accepting it.  <br/><br/>Normally I'd try and cast the object into the format expected by the method but I know you can't do that with generics.  Can anyone post the correct code snippet?  TIA.  - Dave Graper, Albany NY]]></description>
<pubDate>Mon, 07 Apr 2008 07:52:02 GMT</pubDate>
</item>
</channel>
</rss>
