<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.chapleau.info/cs/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Frederick Chapleau .NET Tip of the Day</title><subtitle type="html" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/atom.aspx</id><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/default.aspx" /><link rel="self" type="application/atom+xml" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/atom.aspx" /><generator uri="http://communityserver.org" version="3.1.20917.1142">Community Server</generator><updated>2009-07-18T19:19:00Z</updated><entry><title>A generic way to call ExecuteScalar</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/05/a-generic-way-to-call-executescalar.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/05/a-generic-way-to-call-executescalar.aspx</id><published>2010-02-05T12:16:38Z</published><updated>2010-02-05T12:16:38Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Database Access" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Database+Access/default.aspx" /></entry><entry><title>Multi Line string in C#</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/02/multi-line-string-in-c.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/02/multi-line-string-in-c.aspx</id><published>2010-02-02T15:57:49Z</published><updated>2010-02-02T15:57:49Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Strings" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Strings/default.aspx" /></entry><entry><title>Usage of static constant for SQL Statements</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/01/usage-of-static-constant-for-sql-statements.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/02/01/usage-of-static-constant-for-sql-statements.aspx</id><published>2010-02-01T18:01:00Z</published><updated>2010-02-01T18:01:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Database Access" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Database+Access/default.aspx" /></entry><entry><title>WebService Prefix</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/27/webservice-prefix.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/27/webservice-prefix.aspx</id><published>2010-01-27T15:23:46Z</published><updated>2010-01-27T15:23:46Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Documentation" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Documentation/default.aspx" /></entry><entry><title>Use internal instead of public</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/04/use-internal-instead-of-public.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2010/01/04/use-internal-instead-of-public.aspx</id><published>2010-01-04T12:42:37Z</published><updated>2010-01-04T12:42:37Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Interfaces" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Interfaces/default.aspx" /></entry><entry><title>The params keyword, when a single argument is not enough</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/27/the-params-keyword-when-a-single-argument-is-not-enough.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/27/the-params-keyword-when-a-single-argument-is-not-enough.aspx</id><published>2009-07-28T03:53:00Z</published><updated>2009-07-28T03:53:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Shortcuts" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Shortcuts/default.aspx" /></entry><entry><title>Use always the same standard for exceptions and event</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/26/use-always-the-same-standard-for-exceptions-and-event.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/26/use-always-the-same-standard-for-exceptions-and-event.aspx</id><published>2009-07-26T15:11:00Z</published><updated>2009-07-26T15:11:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Error Handling" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Error+Handling/default.aspx" /></entry><entry><title>A new way to handle cleanup</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/25/a-new-way-to-handle-cleanup.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/25/a-new-way-to-handle-cleanup.aspx</id><published>2009-07-26T01:31:00Z</published><updated>2009-07-26T01:31:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Error Handling" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Error+Handling/default.aspx" /></entry><entry><title>Usage of the @</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/24/usage-of-the.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/24/usage-of-the.aspx</id><published>2009-07-24T21:05:00Z</published><updated>2009-07-24T21:05:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Shortcuts" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Shortcuts/default.aspx" /></entry><entry><title>The 3 Strike Method</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/23/the-3-strike-method.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/23/the-3-strike-method.aspx</id><published>2009-07-23T15:40:00Z</published><updated>2009-07-23T15:40:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Refactoring" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Refactoring/default.aspx" /></entry><entry><title>Use the String.Format</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/22/use-the-string-format.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/22/use-the-string-format.aspx</id><published>2009-07-22T12:22:00Z</published><updated>2009-07-22T12:22:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Strings" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Strings/default.aspx" /></entry><entry><title>Explicitly call Dispose</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/21/explicitly-call-dispose.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/21/explicitly-call-dispose.aspx</id><published>2009-07-21T19:23:00Z</published><updated>2009-07-21T19:23:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Optimization" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Optimization/default.aspx" /></entry><entry><title>Improve your startup</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/20/improve-your-startup.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/20/improve-your-startup.aspx</id><published>2009-07-21T03:21:00Z</published><updated>2009-07-21T03:21:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Optimization" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Optimization/default.aspx" /></entry><entry><title>JavaScript Timeout retention</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/19/javascript-timeout-retention.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/19/javascript-timeout-retention.aspx</id><published>2009-07-19T20:22:00Z</published><updated>2009-07-19T20:22:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Web Advanced Design" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Web+Advanced+Design/default.aspx" /></entry><entry><title>CSS Z-Index</title><link rel="alternate" type="text/html" href="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/18/css-z-index.aspx" /><id>http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/2009/07/18/css-z-index.aspx</id><published>2009-07-18T23:19:00Z</published><updated>2009-07-18T23:19:00Z</updated><content type="html">&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;</content><author><name>Frederick.Chapleau</name><uri>http://www.chapleau.info/cs/members/Frederick.Chapleau.aspx</uri></author><category term="Web Advanced Design" scheme="http://www.chapleau.info/cs/blogs/fchapleau_nettip/archive/tags/Web+Advanced+Design/default.aspx" /></entry></feed>