<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.chapleau.info/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Frederick Chapleau .NET Tip of the Day</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>A generic way to call ExecuteScalar</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/05/a-generic-way-to-call-executescalar.aspx</link><pubDate>Fri, 05 Feb 2010 12:16:38 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:827</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=827</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/05/a-generic-way-to-call-executescalar.aspx#comments</comments><description>&lt;p&gt;When calling execute Scalar, we always begin by calling it with some code like&lt;/p&gt;  &lt;p&gt;int i = cmd.ExecuteScalar();&lt;/p&gt;  &lt;p&gt;What’s wrong with this picture?… what if, the first field of the first row is… NULL?&lt;/p&gt;  &lt;p&gt;so…&lt;/p&gt;  &lt;p&gt;int i;   &lt;br /&gt;object o = cmd.ExecuteScalar();    &lt;br /&gt;if(o != null)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; i = (int)o;&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=827" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Database+Access/default.aspx">Database Access</category></item><item><title>Multi Line string in C#</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/02/multi-line-string-in-c.aspx</link><pubDate>Tue, 02 Feb 2010 15:57:49 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:825</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=825</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/02/multi-line-string-in-c.aspx#comments</comments><description>&lt;p&gt;Ever wonder of a more efficient way to write multiple lines strings?&lt;/p&gt;  &lt;p&gt;Check this out…&lt;/p&gt;  &lt;p&gt;The first way...&lt;/p&gt;  &lt;pre&gt;string myString1 = &amp;quot;This is the first line of my string.\n&amp;quot; +
                   &amp;quot;This is the second line of my string.\n&amp;quot; +
                   &amp;quot;This is the third line of the string.\n&amp;quot;;&lt;/pre&gt;

&lt;pre&gt;&lt;font face="Tahoma"&gt;And a more efficient way...&lt;/font&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;font face="Tahoma"&gt;&lt;/font&gt;
string myString2 = @&amp;quot;This is the first line of my string.
This is the second line of my string.
This is the third line of the string.&amp;quot;;&lt;/pre&gt;

&lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=825" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Strings/default.aspx">Strings</category></item><item><title>Usage of static constant for SQL Statements</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/01/usage-of-static-constant-for-sql-statements.aspx</link><pubDate>Mon, 01 Feb 2010 18:01:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:826</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=826</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/01/usage-of-static-constant-for-sql-statements.aspx#comments</comments><description>&lt;p&gt;Embedding SQL statement is sometimes useful. A good practice is to centralize them in a class, using public constants...&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;public const string SQL_MYTABLE_INSERT = &amp;quot;INSERT MYTABLE (FIELD) VALUES (@FIELDVALUE)&amp;quot;;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=826" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Database+Access/default.aspx">Database Access</category></item><item><title>WebService Prefix</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/27/webservice-prefix.aspx</link><pubDate>Wed, 27 Jan 2010 15:23:46 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:823</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=823</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/27/webservice-prefix.aspx#comments</comments><description>&lt;p&gt;When adding a web service to your 2.0 .NET project, always begin by the same prefix, so, when the code will be generated, the namespace using will always be the same... like WebService.TheWSName and WebService.TheSecondWSName...&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=823" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Documentation/default.aspx">Documentation</category></item><item><title>Use internal instead of public</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/04/use-internal-instead-of-public.aspx</link><pubDate>Mon, 04 Jan 2010 12:42:37 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:819</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=819</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/04/use-internal-instead-of-public.aspx#comments</comments><description>&lt;p&gt;For production product, usage of public should be only used for publicly accessible methods, because all public methods can be used by other assembly/application than yours.&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=819" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Interfaces/default.aspx">Interfaces</category></item><item><title>The params keyword, when a single argument is not enough</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/27/the-params-keyword-when-a-single-argument-is-not-enough.aspx</link><pubDate>Tue, 28 Jul 2009 03:53:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:785</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=785</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/27/the-params-keyword-when-a-single-argument-is-not-enough.aspx#comments</comments><description>&lt;p&gt;When you don’t want to provide a fixed number of argument for a method, you can use the params modifier, that can handle a list of values of a single type, instead of requiring from the caller to build a list.&lt;/p&gt;  &lt;pre&gt;void UseParams(params int[] list)&lt;/pre&gt;

&lt;p&gt;-f.&lt;/p&gt;

&lt;p&gt;ref.: &lt;a href="http://msdn.microsoft.com/en-us/library/w5zay9db.aspx"&gt;http://msdn.microsoft.com/en-us/library/w5zay9db.aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=785" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Shortcuts/default.aspx">Shortcuts</category></item><item><title>Use always the same standard for exceptions and event</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/26/use-always-the-same-standard-for-exceptions-and-event.aspx</link><pubDate>Sun, 26 Jul 2009 15:11:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:784</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=784</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/26/use-always-the-same-standard-for-exceptions-and-event.aspx#comments</comments><description>&lt;p&gt;e is not enough... usually handle event as an “e”, and exceptions as an “ex” &lt;/p&gt;  &lt;p&gt;...sorry, it too obvious ;)&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=784" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Error+Handling/default.aspx">Error Handling</category></item><item><title>A new way to handle cleanup</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/25/a-new-way-to-handle-cleanup.aspx</link><pubDate>Sun, 26 Jul 2009 01:31:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:783</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=783</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/25/a-new-way-to-handle-cleanup.aspx#comments</comments><description>&lt;p&gt;You should know about the try{}catch{} block. But did you know that you can use a try{}finally{} block?&lt;/p&gt;  &lt;p&gt;So when an error is raised, you are sure that the statements in the finally block are executed.&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=783" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Error+Handling/default.aspx">Error Handling</category></item><item><title>Usage of the @</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/24/usage-of-the.aspx</link><pubDate>Fri, 24 Jul 2009 21:05:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:782</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=782</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/24/usage-of-the.aspx#comments</comments><description>&lt;p&gt;In C#, when you have a string with slash in it, you must double it to have a result of only one, because of the escape code.&lt;/p&gt;  &lt;p&gt;When starting a string with a @, you can’t insert escape code, but you do not have to double them.&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=782" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Shortcuts/default.aspx">Shortcuts</category></item><item><title>The 3 Strike Method</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/23/the-3-strike-method.aspx</link><pubDate>Thu, 23 Jul 2009 15:40:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:781</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=781</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/23/the-3-strike-method.aspx#comments</comments><description>&lt;p&gt;1. You write it, as good as you think it should be implemented.&lt;/p&gt;  &lt;p&gt;2. You realize that it can be better, you can improve it.&lt;/p&gt;  &lt;p&gt;3. The last time you touch it, after that it can only be worst.&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=781" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Refactoring/default.aspx">Refactoring</category></item><item><title>Use the String.Format</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/22/use-the-string-format.aspx</link><pubDate>Wed, 22 Jul 2009 12:22:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:780</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=780</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/22/use-the-string-format.aspx#comments</comments><description>&lt;p&gt;You can a string using a standard.Comparable to the sprintf C format...&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;  &lt;p&gt;ref.: &lt;a href="http://msdn.microsoft.com/en-us/library/system.string.format(VS.71).aspx"&gt;http://msdn.microsoft.com/en-us/library/system.string.format(VS.71).aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=780" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Strings/default.aspx">Strings</category></item><item><title>Explicitly call Dispose</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/21/explicitly-call-dispose.aspx</link><pubDate>Tue, 21 Jul 2009 19:23:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:779</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=779</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/21/explicitly-call-dispose.aspx#comments</comments><description>&lt;p&gt;Calling Dispose release resources immediately, that can be useful for big files, handles etc...&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=779" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Optimization/default.aspx">Optimization</category></item><item><title>Improve your startup</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/20/improve-your-startup.aspx</link><pubDate>Tue, 21 Jul 2009 03:21:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:778</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=778</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/20/improve-your-startup.aspx#comments</comments><description>&lt;p&gt;Use SGEN to generate the XML Generation assembly, it can be improved from milliseconds to minutes...&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bk3w6240(VS.80).aspx"&gt;http://msdn.microsoft.com/en-us/library/bk3w6240(VS.80).aspx&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=778" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Optimization/default.aspx">Optimization</category></item><item><title>JavaScript Timeout retention</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/19/javascript-timeout-retention.aspx</link><pubDate>Sun, 19 Jul 2009 20:22:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:775</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=775</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/19/javascript-timeout-retention.aspx#comments</comments><description>&lt;p&gt;Timeout are used since… well… since the dynamic web exists. But the returned timeout variable (usally a number) can be used to stop them. A good hint is to always store it somewhere, so that you can easily cancel them later.&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=775" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Web+Advanced+Design/default.aspx">Web Advanced Design</category></item><item><title>CSS Z-Index</title><link>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/18/css-z-index.aspx</link><pubDate>Sat, 18 Jul 2009 23:19:00 GMT</pubDate><guid isPermaLink="false">e7246f0f-dd1f-46e9-867a-eed8df1342ba:774</guid><dc:creator>Frederick.Chapleau</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.chapleau.info/cs/blogs/fchapleau_nettip/rsscomments.aspx?PostID=774</wfw:commentRss><comments>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/18/css-z-index.aspx#comments</comments><description>&lt;p&gt;A great layout tips... Overlay!&lt;/p&gt;  &lt;p&gt;The Zindex CSS property can priories the layout order. A kind of Bring Forward and Send to Back.&lt;/p&gt;  &lt;p&gt;-f.&lt;/p&gt;&lt;img src="http://www.chapleau.info/cs/aggbug.aspx?PostID=774" width="1" height="1"&gt;</description><category domain="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Web+Advanced+Design/default.aspx">Web Advanced Design</category></item></channel></rss>