<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://dineshpriyankara.spaces.live.com/mmm2008-05-17_13.22/rsspretty.aspx?rssquery=en-US;http%3a%2f%2fdineshpriyankara.spaces.live.com%2fcategory%2f__x1NET%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Dinesh's Blog             ::::::: Being Compiled :::::::: .NET</title><description /><link>http://dineshpriyankara.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&amp;_c=BlogPart&amp;partqs=cat__x1NET</link><language>en-US</language><pubDate>Thu, 26 Jun 2008 19:40:52 GMT</pubDate><lastBuildDate>Thu, 26 Jun 2008 19:40:52 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><cf:parentRSS>http://dineshpriyankara.spaces.live.com/blog/feed.rss</cf:parentRSS><live:type>blogcategory</live:type><live:identity><live:id>4683496953178731031</live:id><live:alias>dineshpriyankara</live:alias></live:identity><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>Wanna images with patterns</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!558.entry</link><description>&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Found these two images while surfing in .net and sql blogs. These were published by &lt;a href="http://codebetter.com/blogs/raymond.lewallen/"&gt;&lt;strong&gt;Raymond Lewallen [MVP&lt;/strong&gt;&lt;/a&gt;]. I found that they are very important though it is little bit difficult to read. But worthwhile to keep them with you if you really interesting in OOP with patterns.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;&lt;div&gt;&lt;table cellspacing="0" border="0"&gt;&lt;tr height="8"&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign="top"&gt;&lt;p&gt;&lt;a href="http://blufiles.storage.live.com&amp;#47;y1pt6CjYtpbdo1Ti_QbX-0BKOtc10VIe5vUrQIJ5C9IvkNj3v8SkRaU_AhNYuI13a-k"&gt;&lt;img src="http://storage.live.com&amp;#47;items&amp;#47;40FF1FAA28D7B217&amp;#33;560&amp;#58;thumbnail" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width="15"&gt;&lt;/td&gt;&lt;td valign="top"&gt;&lt;p&gt;&lt;a href="http://blufiles.storage.live.com&amp;#47;y1pD_ie6pmGFnDKMPCc3R_OmUgzy5k5FfWLFD0HIORrxsJrNgLw9Krds4O89mllcbi5"&gt;&lt;img src="http://storage.live.com&amp;#47;items&amp;#47;40FF1FAA28D7B217&amp;#33;559&amp;#58;thumbnail" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;&lt;td width="15"&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Wanna+images+with+patterns&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!558.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!558.entry</guid><pubDate>Wed, 07 Jun 2006 04:00:43 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!558/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!558.entry#comment</wfw:comment><dcterms:modified>2006-06-07T04:02:18Z</dcterms:modified></item><item><title>CSM – First Batch - ASP.NET completed</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!447.entry</link><description>&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;My first batch at &lt;a href="http://www.csmict.com/"&gt;CSM&lt;/a&gt;, completed their ASP.NET course, hope they got something from me. I tried as much as possible to give them more things related to C# and ASP.NET, sharing my experience. Sometimes I felt that the samples I used to explain some scenario are too complex for them but most of them grabbed it without mush problem. I couldn’t cover all the topics I wanted regarding ASP.NET because of the time but fundamentals and important topics. I just wanted to give them a feedback form – just to see how I have helped them – but couldn’t. I might be able to get a feedback from them when they come to exam &lt;img src="/rte/emoticons/smile_wink.gif"&gt;. Good to see that some students are coming to my Windows class too.&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+CSM+%e2%80%93+First+Batch+-+ASP.NET+completed&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!447.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!447.entry</guid><pubDate>Mon, 03 Apr 2006 01:14:13 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!447/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!447.entry#comment</wfw:comment><dcterms:modified>2006-04-03T01:14:13Z</dcterms:modified></item><item><title>WMI is not smart enough to find my HD serial number</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!420.entry</link><description>&lt;div&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;I was used to get the volume serial number instead HD serial number for registration purposes but changed the plan couple of months back because of the possibility of changing the volume serial numbers. Then I have been using WMI for access my HD serial number and it worked fine until yesterday. Yep, it didn’t show the serial number of my new HD.&lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt; &lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;While surfing for new stuff, found a very good post “&lt;a href="http://addressof.com/blog/archive/2004/02/14/392.aspx"&gt;Revenge of DriveInfo&lt;/a&gt;” that access all I need with VB.Net code that is the translated of APIs. Seems this can be used for future application but need to test it carefully.&lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt; &lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Have a look and see. It might be helpful to you all.&lt;br&gt; &lt;/font&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+WMI+is+not+smart+enough+to+find+my+HD+serial+number&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!420.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!420.entry</guid><pubDate>Fri, 20 Jan 2006 01:36:45 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!420/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!420.entry#comment</wfw:comment><dcterms:modified>2006-01-20T01:36:45Z</dcterms:modified></item><item><title>Colleagues don’t use this method. It is obsolete.</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!399.entry</link><description>&lt;div&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Think about an instance that you need a method to be hidden (in other words, keep the method as a reference) not to be deleted. How do you do it? I used to add region pre-processor directives but sometimes it made the code little bit complex. The best option is ObsoleteAttribute that takes care about this situation (I wonder why didn’t I use it). We can simply tag the method as “Obsolete” that gives compiler-warning after. Not only that, the method can be set as “Not to use” that gives compiler-error. &lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;[&lt;font color="#008080"&gt;ObsoleteAttribute&lt;/font&gt;(&lt;font color="#800000"&gt;&amp;quot;This method should only be used in DEBUG mode.&amp;quot;&lt;/font&gt;)]&lt;br&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public void&lt;/font&gt; MyMethod1()&lt;br&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;{&lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif"&gt;&lt;font size=1&gt;   &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;MyMethod1 is exeuted&amp;quot;&lt;/font&gt;);&lt;/font&gt;&lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;}&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;[&lt;font color="#008080"&gt;ObsoleteAttribute&lt;/font&gt;(&lt;font color="#800000"&gt;&amp;quot;This method should not be used.&amp;quot;&lt;/font&gt;, &lt;font color="#0000ff"&gt;true&lt;/font&gt;)]&lt;br&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public void &lt;/font&gt;MyMethod2()&lt;br&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;{&lt;/font&gt;
&lt;p style=""&gt;&lt;font size=1&gt;&lt;font face=Verdana&gt;&lt;span style=""&gt;   &lt;/span&gt;&lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#800000"&gt;&amp;quot;MyMethod2 is exeuted&amp;quot;&lt;/font&gt;);&lt;br&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;}&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The warning (what we have set with positional parameter) will be displayed at the compile time for method1 but the second positional parameter that is added to the Method2 forces to compiler error.&lt;br&gt;&lt;br&gt;&lt;/font&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Did you find it really useful?&lt;br&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Colleagues+don%e2%80%99t+use+this+method.+It+is+obsolete.&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!399.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!399.entry</guid><pubDate>Mon, 02 Jan 2006 01:05:26 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!399/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!399.entry#comment</wfw:comment><dcterms:modified>2006-01-02T01:05:26Z</dcterms:modified></item><item><title>Common mistakes we might make</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!384.entry</link><description>&lt;div&gt;&lt;strong&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Not qualifying instance members&lt;/font&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This is a very common mistake we make. Have a look on below code sample.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;class &lt;/font&gt;&lt;font color="#008080"&gt;Employee&lt;/font&gt;&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;private string &lt;/font&gt;firstName;&lt;br&gt;   &lt;font color="#0000ff"&gt;private string&lt;/font&gt; lastName;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public &lt;/font&gt;Employee(&lt;font color="#0000ff"&gt;string &lt;/font&gt;firstName, &lt;font color="#0000ff"&gt;string &lt;/font&gt;lastName)&lt;br&gt;   {&lt;br&gt;      firstName = firstName;&lt;br&gt;      lastName = lastName;&lt;br&gt;   }&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public void&lt;/font&gt; PrintName()&lt;br&gt;   {&lt;br&gt;       &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(&lt;font color="#993300"&gt;&amp;quot;Name is {0} {1}&amp;quot;&lt;/font&gt;, firstName, lastName);&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Though we assign the firstName and lastName via constructor, values will not be set since the instance members are hidden by the parameters. One way to overcome this is, name the class members with “_” like “_firstName”. But I think the better way is, qualifying the class instance members with “this” keyword. This is one of the ways in which the “this” reference is typically used.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public &lt;/font&gt;Employee(&lt;font color="#0000ff"&gt;string &lt;/font&gt;firstName, &lt;font color="#0000ff"&gt;string &lt;/font&gt;lastName)&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;this&lt;/font&gt;.firstName = firstName;&lt;br&gt;   &lt;font color="#0000ff"&gt;this&lt;/font&gt;.lastName = lastName;&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;Remove items from the collection via looping with “for”&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The below code loads instances of tickets into ArrayList and loops with “for”. Note that it sets the “IsValid” member to “true” for all tickets and removes the second ticket (which id is 2) from the collection. This remove causes inaccessibility of 3rd ticket (which id is 3) and because of this, 3rd ticket’s “IsValid” member will not be set as “true”.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;Ticket&lt;/font&gt;&lt;br&gt;{&lt;br&gt;  &lt;font color="#0000ff"&gt; public int &lt;/font&gt;Id { &lt;font color="#0000ff"&gt;get &lt;/font&gt;{ &lt;font color="#0000ff"&gt;return &lt;/font&gt;_id; } &lt;font color="#0000ff"&gt;set &lt;/font&gt;{ _id = &lt;font color="#0000ff"&gt;value&lt;/font&gt;; } }&lt;br&gt;   &lt;font color="#0000ff"&gt;private int&lt;/font&gt; _id;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public bool&lt;/font&gt; IsFullyPaid { &lt;font color="#0000ff"&gt;get &lt;/font&gt;{ &lt;font color="#0000ff"&gt;return &lt;/font&gt;_isFullyPaid; } &lt;font color="#0000ff"&gt;set &lt;/font&gt;{ _isFullyPaid = &lt;font color="#0000ff"&gt;value&lt;/font&gt;; } }&lt;br&gt;   &lt;font color="#0000ff"&gt;private bool&lt;/font&gt; _isFullyPaid;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public bool&lt;/font&gt; IsValid { &lt;font color="#0000ff"&gt;get &lt;/font&gt;{ &lt;font color="#0000ff"&gt;return &lt;/font&gt;_isValid; } &lt;font color="#0000ff"&gt;set &lt;/font&gt;{ _isValid = &lt;font color="#0000ff"&gt;value&lt;/font&gt;; } }&lt;br&gt;   &lt;font color="#0000ff"&gt;private bool&lt;/font&gt; _isValid = &lt;font color="#0000ff"&gt;false&lt;/font&gt;;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public &lt;/font&gt;Ticket(&lt;font color="#0000ff"&gt;int &lt;/font&gt;id, &lt;font color="#0000ff"&gt;bool &lt;/font&gt;isFullyPaid)&lt;br&gt;   {&lt;br&gt;      &lt;font color="#0000ff"&gt;this&lt;/font&gt;._id = id;&lt;br&gt;      &lt;font color="#0000ff"&gt;this&lt;/font&gt;._isFullyPaid = isFullyPaid;&lt;br&gt;      &lt;font color="#0000ff"&gt;this&lt;/font&gt;._isValid = &lt;font color="#0000ff"&gt;false&lt;/font&gt;;&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#008080"&gt;ArrayList &lt;/font&gt;tickets = &lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#008080"&gt;ArrayList&lt;/font&gt;();&lt;br&gt;tickets.Add(&lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#008080"&gt;Ticket&lt;/font&gt;(1, &lt;font color="#0000ff"&gt;true&lt;/font&gt;));&lt;br&gt;tickets.Add(&lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#008080"&gt;Ticket&lt;/font&gt;(2, &lt;font color="#0000ff"&gt;false&lt;/font&gt;));&lt;br&gt;tickets.Add(&lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#008080"&gt;Ticket&lt;/font&gt;(3, &lt;font color="#0000ff"&gt;true&lt;/font&gt;));&lt;br&gt;tickets.Add(&lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#008080"&gt;Ticket&lt;/font&gt;(4, &lt;font color="#0000ff"&gt;true&lt;/font&gt;));&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;for &lt;/font&gt;(&lt;font color="#0000ff"&gt;int &lt;/font&gt;x = 0; x &amp;lt; tickets.Count; x++)&lt;br&gt;{&lt;br&gt;   ((&lt;font color="#008080"&gt;Ticket&lt;/font&gt;)tickets[x]).IsValid = &lt;font color="#0000ff"&gt;true&lt;/font&gt;;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;if &lt;/font&gt;(!((&lt;font color="#008080"&gt;Ticket&lt;/font&gt;)tickets[x]).IsFullyPaid)&lt;br&gt;      tickets.Remove(((&lt;font color="#008080"&gt;Ticket&lt;/font&gt;)tickets[x]));&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;foreach &lt;/font&gt;(&lt;font color="#008080"&gt;Ticket &lt;/font&gt;ticket &lt;font color="#0000ff"&gt;in &lt;/font&gt;tickets)&lt;br&gt;{&lt;br&gt;   &lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(ticket.Id + &lt;font color="#993300"&gt;&amp;quot;: &amp;quot;&lt;/font&gt; + ticket.IsValid);&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Remember this behavior when you use “for” for collections. This is not an odd behavior but I have made this mistake for some codes and you might too.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Common+mistakes+we+might+make&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!384.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!384.entry</guid><pubDate>Tue, 29 Nov 2005 01:47:23 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!384/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!384.entry#comment</wfw:comment><dcterms:modified>2005-11-29T01:47:23Z</dcterms:modified></item><item><title>Letting “new” to be used for derived methods</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!295.entry</link><description>&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;While searching the culprit for unexpected result generated by one of façades, found a small mistake I have made in one of my classes. Yes, the culprit is a derived method that is not preceded with either new or override keywords. This caused to compile the method with new keyword and, of course, it will always execute the base method instead of derived method if base class is used for declaration. Though to share the problem as well as the solution I made because it might help you on your next design. See the sample code.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;Employee&lt;/font&gt;&lt;br&gt;{&lt;br&gt;&lt;font color="#0000ff"&gt;protected string&lt;/font&gt; _name;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public virtual string&lt;/font&gt; Name { &lt;font color="#0000ff"&gt;get &lt;/font&gt;{ &lt;font color="#0000ff"&gt;return &lt;/font&gt;&amp;quot;Employee name is &amp;quot; + _name; } }&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public &lt;/font&gt;Employee(&lt;font color="#0000ff"&gt;string &lt;/font&gt;name)&lt;br&gt;{&lt;br&gt;_name = name;&lt;br&gt;}&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;Manager &lt;/font&gt;: &lt;font color="#008080"&gt;Employee&lt;/font&gt;&lt;br&gt;{&lt;br&gt;&lt;font color="#0000ff"&gt;public &lt;/font&gt;Manager(&lt;font color="#0000ff"&gt;string &lt;/font&gt;name)&lt;br&gt;: &lt;font color="#0000ff"&gt;base&lt;/font&gt;(name)&lt;br&gt;{&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public string&lt;/font&gt; Name { &lt;font color="#0000ff"&gt;get &lt;/font&gt;{ &lt;font color="#0000ff"&gt;return &lt;/font&gt;&amp;quot;Manager name is &amp;quot; + &lt;font color="#0000ff"&gt;base&lt;/font&gt;._name; } }&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The “Employee” is the base class and Manager is the derived class. The expected result for below code is “Manager name is Dinesh” but the will resulted as “Employee name is Dinesh”. This is because of the “Name” property of Manager class is compiled with new keyword.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#008080"&gt;Employee &lt;/font&gt;employee = &lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#008080"&gt;Manager&lt;/font&gt;(&amp;quot;Dinesh&amp;quot;);&lt;br&gt;&lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(employee.Name);&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Now see the new code. This will give us the expected result because the method is preceded with “override”.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; &lt;font color="#008080"&gt;Manager &lt;/font&gt;: &lt;font color="#008080"&gt;Employee&lt;/font&gt;&lt;br&gt;{&lt;br&gt;&lt;font color="#0000ff"&gt;public &lt;/font&gt;Manager(&lt;font color="#0000ff"&gt;string &lt;/font&gt;name)&lt;br&gt;: &lt;font color="#0000ff"&gt;base&lt;/font&gt;(name)&lt;br&gt;{&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public override string&lt;/font&gt; Name { &lt;font color="#0000ff"&gt;get &lt;/font&gt;{ &lt;font color="#0000ff"&gt;return &lt;/font&gt;&amp;quot;Manager name is &amp;quot; + &lt;font color="#0000ff"&gt;base&lt;/font&gt;._name; } }&lt;br&gt;}&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#008080"&gt;Employee &lt;/font&gt;employee = &lt;font color="#0000ff"&gt;new &lt;/font&gt;&lt;font color="#008080"&gt;Manager&lt;/font&gt;(&amp;quot;Dinesh&amp;quot;);&lt;br&gt;&lt;font color="#008080"&gt;Console&lt;/font&gt;.WriteLine(employee.Name);&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The .net compiler will treat methods that are not preceded with “new” or “override” as “new” methods. But it seems that the behavior of java compiler is little bit differnet. I think that Java compiler will treat this kind of methods as overriden. Am I right?&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Letting+%e2%80%9cnew%e2%80%9d+to+be+used+for+derived+methods&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!295.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!295.entry</guid><pubDate>Wed, 21 Sep 2005 15:07:31 GMT</pubDate><slash:comments>5</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!295/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!295.entry#comment</wfw:comment><dcterms:modified>2005-09-21T15:07:31Z</dcterms:modified></item><item><title>Passing Custom Collection to the web service?</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!249.entry</link><description>&lt;div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Passing Custom Collection via Web Service is impossible? For me, it seems it is impossible. The Custom Collection is represented as an Array instead of a collection at the client side (consumer side). Though it is as an Array at the client side, the web service works fine. Have a look in my code in web service.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;[WebMethod]&lt;br&gt;&lt;font color="#0000ff"&gt;public &lt;/font&gt;EmployeeCollection UpdateEmployees (EmployeeCollection employeeCollection)&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;foreach&lt;/font&gt;(Employee employee &lt;font color="#0000ff"&gt;in &lt;/font&gt;employeeCollection)&lt;br&gt;   {&lt;br&gt;      employee.LastName = employee.LastName + &amp;quot;Updated&amp;quot;;&lt;br&gt;   }&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;return &lt;/font&gt;employeeCollection;&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Sample classes I made for testing&lt;br&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; Employee&lt;br&gt;{&lt;br&gt;  &lt;font color="#0000ff"&gt; private int &lt;/font&gt;_id;&lt;br&gt;   &lt;font color="#0000ff"&gt;private string&lt;/font&gt; _lastName;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#0000ff" size=1&gt;   &lt;font color="#000000"&gt;&lt;font color="#0000ff"&gt;public int&lt;/font&gt; Id {&lt;font color="#0000ff"&gt;get &lt;/font&gt;{&lt;font color="#0000ff"&gt;return &lt;/font&gt;_id;} &lt;font color="#0000ff"&gt;set &lt;/font&gt;{_id = &lt;font color="#0000ff"&gt;value&lt;/font&gt;;}}&lt;br&gt;   &lt;font color="#0000ff"&gt;public string&lt;/font&gt; LastName {&lt;font color="#0000ff"&gt;get &lt;/font&gt;{&lt;font color="#0000ff"&gt;return &lt;/font&gt;_lastName;} &lt;font color="#0000ff"&gt;set &lt;/font&gt;{_lastName = &lt;font color="#0000ff"&gt;value&lt;/font&gt;;}}&lt;br&gt;&lt;/font&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; EmployeeCollection : CollectionBase&lt;br&gt;{&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public void&lt;/font&gt; Add(Employee employee)&lt;br&gt;   {&lt;br&gt;      List.Add(employee);&lt;br&gt;   }&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public void&lt;/font&gt; Remove(Employee employee)&lt;br&gt;   {&lt;br&gt;      &lt;font color="#0000ff"&gt;if &lt;/font&gt;(List.Contains(employee))&lt;br&gt;         List.Remove(employee);&lt;br&gt;   }&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public &lt;/font&gt;Employee &lt;font color="#0000ff"&gt;this &lt;/font&gt;[&lt;font color="#0000ff"&gt;int &lt;/font&gt;index]&lt;br&gt;   {&lt;br&gt;      &lt;font color="#0000ff"&gt;get&lt;/font&gt;&lt;br&gt;      {&lt;br&gt;         &lt;font color="#0000ff"&gt;if &lt;/font&gt;(index &amp;gt;= 0 &amp;amp;&amp;amp; index &amp;lt; List.Count)&lt;br&gt;            &lt;font color="#0000ff"&gt;return &lt;/font&gt;(Employee) List[index];&lt;br&gt;         &lt;font color="#0000ff"&gt;else&lt;/font&gt;&lt;br&gt;            &lt;font color="#0000ff"&gt;return null&lt;/font&gt;;&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;}&lt;br&gt;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Once the web service is added to the consumer application, The “UpdateEmployees” method is shown as;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;WebSeriveConsumer.WebServiceTest.Employee[] ServiceTest.UpdateEmployees(WebSeriveConsumer.WebServiceTest.Employee[] employeeCollection)&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;I made a search on the internet for seeing a solution for this but not found a proper solution. One of the suggestions found was; changing the web service’s reference.cs file in consumer application. Yes, I changed the file (Adding a collection class to the reference.cs file and change all “Employee[]” to “EmployeeCollection”) and then it worked fine. I am not sure whether the way I changed file is correct or not because there is only a suggestion but information.  But the biggest drawback with this solution is; it is needed to change the file again and again if the web service is updated. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Another issue I’m having with web service is, even though the class (either Employee or EmployeeCollection) is declared at the client side (consumer side), it cannot be used for passing to the web service because it is consider as a different object at the web service side. This causes to convert the object that is created with consumer declaration to web service type object. It seems this can be worked around by applying “Operator Overloading”. Is it a good idea? Or the declaration of the classes that use in the webservice at the client side is worthless? &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Having lot of confuses in my mind, I started finding a solution for all of these with XMLSerialization. It might give me a nice solution for all. Anyway it is being tested.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Hope you guys experienced this type of problems and solved with some proper manner. Would you like to share your solution with me?&lt;/font&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Passing+Custom+Collection+to+the+web+service%3f&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!249.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!249.entry</guid><pubDate>Sun, 17 Jul 2005 02:17:18 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!249/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!249.entry#comment</wfw:comment><dcterms:modified>2005-07-17T02:17:18Z</dcterms:modified></item><item><title>Assignment Operators cannot be overloaded, but "+=". How?</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!245.entry</link><description>&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;If you have played with &amp;quot;&lt;strong&gt;&lt;font color="#993300"&gt;Operator Overloading&lt;/font&gt;&lt;/strong&gt;&amp;quot; techniques, definitely you know the flexibility it turns on. For example, assume that you have a business object class called &amp;quot;&lt;em&gt;Employee&lt;/em&gt;&amp;quot; and collection class called &amp;quot;&lt;em&gt;EmployeeCollection&lt;/em&gt;&amp;quot; that hold Employee objects. The implementing &amp;quot;+&amp;quot; operator in &amp;quot;Employee&amp;quot;, let you to have a code like below.&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Employee employee1 = &lt;font color="#0000ff"&gt;new &lt;/font&gt;Employee();&lt;br&gt;Employee employee2 = &lt;font color="#0000ff"&gt;new &lt;/font&gt;Employee();&lt;br&gt;EmployeeCollection employeeCollection  = employee1 + employee2;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Think that how nice it is if we can write something like this:&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;employeeCollection += employee1;&lt;br&gt;employeeCollection += employee2;&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;But the problem is the operator &amp;quot;+=&amp;quot;. This cannot be overloaded. So, what's workaround? Simply use the operator &amp;quot;+&amp;quot; for &amp;quot;+=&amp;quot; too. See the code below. &lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#008000"&gt;//this allows to have code like: EmpployeeCollection = Employee1 + Employee2&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;public static &lt;/font&gt;EmployeeCollection &lt;font color="#0000ff"&gt;operator&lt;/font&gt;+(Employee employee1, Employee employee2)&lt;br&gt;{&lt;br&gt;EmployeeCollection employeeCollection = &lt;font color="#0000ff"&gt;new &lt;/font&gt;EmployeeCollection();&lt;br&gt;employeeCollection.Add(employee1);&lt;br&gt;employeeCollection.Add(employee2);&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;return &lt;/font&gt;employeeCollection;&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#008000"&gt;//this allows to have code like: EmpployeeCollection += employee1&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;public static&lt;/font&gt; EmployeeCollection &lt;font color="#0000ff"&gt;operator&lt;/font&gt;+ (EmployeeCollection employeeCollection, Employee employee)&lt;br&gt;{&lt;br&gt;employeeCollection.Add(employee);&lt;br&gt;&lt;font color="#0000ff"&gt;return &lt;/font&gt;employeeCollection;&lt;br&gt;}&lt;/font&gt;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Done! Now the code: &lt;em&gt;&lt;font color="#808080"&gt;employeeCollection += employee1 &lt;/font&gt;&lt;/em&gt;is possible. How nice?&lt;/font&gt;&lt;/div&gt;
&lt;div&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Assignment+Operators+cannot+be+overloaded%2c+but+%22%2b%3d%22.+How%3f&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!245.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!245.entry</guid><pubDate>Tue, 12 Jul 2005 01:40:46 GMT</pubDate><slash:comments>3</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!245/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!245.entry#comment</wfw:comment><dcterms:modified>2005-07-12T01:40:46Z</dcterms:modified></item><item><title>Wanna call server side methods asynchronously at client side? Use Ajax</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!244.entry</link><description>&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Yesterday, &lt;a href="http://www.merill.net"&gt;Merill&lt;/a&gt;, at the dot net group meeting, came up with cool stuff called “&lt;a href="http://ajax.schwarz-interactive.de/csharpsample/default.aspx"&gt;&lt;font color="#993300"&gt;&lt;strong&gt;Ajax&lt;/strong&gt;&lt;/font&gt;&lt;/a&gt;” that contains a set of libraries that serializes .net objects and makes them available at client side. Basically, this allows us to call server side methods from the client side both synchronously and asynchronously. As I was looking for this type of library very badly, started exploring “&lt;strong&gt;&lt;a href="http://ajax.schwarz-interactive.de/csharpsample/default.aspx"&gt;&lt;font color="#800000"&gt;Ajax&lt;/font&gt;&lt;/a&gt;&lt;/strong&gt;” with some of my ASP.Net applications.&lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif"&gt;&lt;font size=1&gt; &lt;/font&gt;&lt;/font&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;I started with various code samples and all of them worked fine. Here is a one of tests I did. This code tracks the dropdown “&lt;em&gt;onchange&lt;/em&gt;” event and call server side method to get the relevant value asynchronously. (The logic behind is, when user selects a Doctor to make an appointment, shows the next available appointment number).&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face=Verdana color="#339966" size=1&gt;//Codes at web page&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;private &lt;/font&gt;&lt;font color="#0000ff"&gt;void &lt;/font&gt;Page_Load(&lt;font color="#0000ff"&gt;object &lt;/font&gt;sender, System.EventArgs e)&lt;br&gt;{&lt;br&gt;   DropDownListDoctors.Attributes.Add(&amp;quot;onchange&amp;quot;, &amp;quot;CallGetNextAppoinmentNumber()&amp;quot;);&lt;br&gt;   Ajax.Utility.RegisterTypeForAjax(&lt;font color="#0000ff"&gt;typeof&lt;/font&gt;(TestPage1));&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;[Ajax.AjaxMethod()]&lt;br&gt;&lt;font color="#0000ff"&gt;public short&lt;/font&gt; GetNextAppoinmentNumber(&lt;font color="#0000ff"&gt;short &lt;/font&gt;doctorId)&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;short &lt;/font&gt;appoinymentNumber;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   //check with database&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;return &lt;/font&gt;appoinymentNumber;&lt;br&gt;}&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#993300"&gt;script &lt;/font&gt;&lt;font color="#ff0000"&gt;language&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;javascript&amp;quot;&lt;/font&gt;&amp;gt;&lt;br&gt;   &lt;font color="#0000ff"&gt;function &lt;/font&gt;CallGetNextAppoinmentNumber()&lt;br&gt;   {&lt;br&gt;      TestPage1.GetNextAppoinmentNumber(document.getElementById(&amp;quot;DropDownListDoctors&amp;quot;).value, GetNextAppoinmentNumber_CallBack);&lt;br&gt;   }&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;&lt;/span&gt; &lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;function &lt;/font&gt;GetNextAppoinmentNumber_CallBack(res)&lt;br&gt;   {&lt;br&gt;      document.getElementById(&amp;quot;LabelAppoinmentNumber&amp;quot;).innerText = res.value;&lt;br&gt;   }&lt;br&gt;&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#993300"&gt;script&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-size:12pt;font-family:'Times New Roman'"&gt;&lt;/span&gt; &lt;/div&gt;
&lt;p style=""&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif"&gt;&lt;font size=1&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;p style=""&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif"&gt;&lt;font size=1&gt;&lt;font color="#000000"&gt;As the method is called asynchronously, user can fill up the rest without any disturbance and see the appointment number even without submitting. &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;p style=""&gt;&lt;span style="font-size:10pt;font-family:'Courier New'"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif"&gt;&lt;font size=1&gt;&lt;font color="#000000"&gt; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#000000" size=1&gt; &lt;/font&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Wanna+call+server+side+methods+asynchronously+at+client+side%3f+Use+Ajax&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!244.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!244.entry</guid><pubDate>Thu, 07 Jul 2005 04:10:31 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!244/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!244.entry#comment</wfw:comment><dcterms:modified>2005-07-07T04:10:31Z</dcterms:modified></item><item><title>IE hit me with another restriction</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!230.entry</link><description>&lt;div&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;One of my applications begins fail at certain level, yes, it is ASP.net application and the reason of failure is IE’s inability of handling nested tables. In one of web pages, dynamic nested tables are being created, earlier the number of nested tables created were around 10 to 20 but with the new extension, it becomes 10 to{ooops, no limit}. Unfortunately, IE handles only 27 nested tables and that makes me to re-think my design. I just had a search on this to see a light at the end of the tunnel but couldn’t find a single solution or sign of up coming IE version with more nested-tables capability. But the sad thing is “Mozilla” handles 33 nested tables.&lt;/font&gt;
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt; &lt;/font&gt;
&lt;p style=""&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; 
&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;See the first HIT at &lt;a href="http://spaces.msn.com/members/dineshpriyankara/Blog/cns!1p-RgJ7SV2D2-6Y3lW0UC8uA!162.entry"&gt;post&lt;/a&gt;.&lt;/font&gt;
&lt;p style=""&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+IE+hit+me+with+another+restriction&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!230.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!230.entry</guid><pubDate>Wed, 29 Jun 2005 03:44:51 GMT</pubDate><slash:comments>5</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!230/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!230.entry#comment</wfw:comment><dcterms:modified>2005-06-29T03:45:09Z</dcterms:modified></item><item><title>Overriding ToString() vs New ToString()</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!227.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Do you override ToString() method in your business classes? I know, most of the time we do not bother but sometime having an new version or overridden ToString() makes our life easier. Few examples are; &lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Have a look on this class:&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; Item&lt;br&gt;{&lt;br&gt;&lt;font color="#3300ff"&gt;   private short&lt;/font&gt; _id;&lt;br&gt;&lt;font color="#3300ff"&gt;   private string&lt;/font&gt; _name;&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#3300ff"&gt;   public &lt;/font&gt;Item(&lt;font color="#3300ff"&gt;byte &lt;/font&gt;id, &lt;font color="#3300ff"&gt;string &lt;/font&gt;name)&lt;br&gt;&lt;font color="#3300ff"&gt;   &lt;/font&gt;{&lt;br&gt;&lt;font color="#3300ff"&gt;      this&lt;/font&gt;._id = id;&lt;br&gt;&lt;font color="#3300ff"&gt;      this&lt;/font&gt;._name = name;&lt;br&gt;&lt;font color="#3300ff"&gt;   &lt;/font&gt;}&lt;/font&gt; &lt;p&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#3300ff"&gt;   public string&lt;/font&gt; ToString()&lt;br&gt;&lt;font color="#3300ff"&gt;   &lt;/font&gt;{&lt;br&gt;&lt;font color="#3300ff"&gt;      return this&lt;/font&gt;._name;&lt;br&gt;&lt;font color="#3300ff"&gt;   &lt;/font&gt;}&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;When you need to output a name of the item from an instance of Item, simply you can write;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Console.WriteLine(item.ToString());&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Another example is; bind a list to DropDownList.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;ArrayList list = &lt;font color="#3300ff"&gt;new &lt;/font&gt;ArrayList();&lt;br&gt;Item item = &lt;font color="#3300ff"&gt;new &lt;/font&gt;Item(1, &amp;quot;Item1&amp;quot;);&lt;br&gt;list.Add(item);&lt;br&gt;item = &lt;font color="#3300ff"&gt;new &lt;/font&gt;Item(2, &amp;quot;Item2&amp;quot;);&lt;br&gt;list.Add(item);&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;DropDownList1.DataSource = list;&lt;br&gt;DropDownList1.DataBind();&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Do we get the result expected? No. What is the problem? As we all know, DropDownList should call ToString() method at binding and display &amp;quot;Item1&amp;quot; and &amp;quot;Item2&amp;quot; instead of &amp;quot;YourApplication.Item&amp;quot; and &amp;quot;YourApplication.Item&amp;quot;. This is because at the binding, it will call base.ToString() (in this case, base is an object class) instead of Item.ToString(). When we impement ToString() without specifying &amp;quot;&lt;font color="#660000"&gt;&lt;strong&gt;new&lt;/strong&gt;&lt;/font&gt;&amp;quot; or &amp;quot;&lt;font color="#660000"&gt;&lt;strong&gt;override&lt;/strong&gt;&lt;/font&gt;&amp;quot;, it will compile as &amp;quot;&lt;strong&gt;&lt;font color="#660000"&gt;new&lt;/font&gt;&lt;/strong&gt;&amp;quot; version and will not override base.ToString(). If we write a code like below;&lt;/font&gt; &lt;p&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#3300ff"&gt;public override string&lt;/font&gt; ToString()&lt;br&gt;{&lt;br&gt;&lt;font color="#3300ff"&gt;   return this&lt;/font&gt;._name;&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;will result as we wanted. So, this is the difference between &amp;quot;&lt;font color="#660000"&gt;&lt;strong&gt;new&lt;/strong&gt;&lt;/font&gt;&amp;quot; and &amp;quot;&lt;font color="#660000"&gt;&lt;strong&gt;override&lt;/strong&gt;&lt;/font&gt;&amp;quot;. Basically, when a method of base class is overridden by derived class, it will call derived method even with the base class implementation with derived class.&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;MyBaseClass myBaseClass = new MyDerivedClass();&lt;br&gt;myBaseClass.Method(); &lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;br&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Overriding+ToString()+vs+New+ToString()&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!227.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!227.entry</guid><pubDate>Mon, 27 Jun 2005 02:25:43 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!227/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!227.entry#comment</wfw:comment><dcterms:modified>2005-06-27T02:25:43Z</dcterms:modified></item><item><title>Max pool size was reached: It happened again</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!226.entry</link><description>&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Have you ever experienced the error of “&lt;font color="#ff0000"&gt;Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached&lt;/font&gt;”. You might have. Last week one of my clients complained that they experienced an error with their application for couple of minutes and worked fine after. The error that occurred was the same as that above mentioned. What is the reason for this? This is because; system is trying to store a connection object in the pool but pool cannot hold any more connections because it has reached the maximum connection objects level. I just noted down some points for connection pool for future references.&lt;/font&gt; &lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt; &lt;/font&gt; &lt;p style=""&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;ul&gt; &lt;li&gt; &lt;div style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;A pool is created based on the connection string for the connection. For each unique connection, ADO.net will create a connection pool.&lt;/font&gt;&lt;/div&gt; &lt;li&gt; &lt;div style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;When a connection is created and opened, ADO.net finds the relevant pool for the connection string and issues a released-connection (that is already added and not currently used). If not (either no connections in the pool or no released-connections), will add it to the pool if it can hold and issue. &lt;/font&gt;&lt;/div&gt; &lt;li&gt; &lt;div style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;If no more objects can be held and no more released-connections to be issued, an exception is thrown after the timeout period expired. &lt;/font&gt;&lt;/div&gt; &lt;li&gt; &lt;div style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;If the connection is not closed after the process, issued-connection will not be added back to the pool and remained as orphaned (un-released)&lt;/font&gt;&lt;/div&gt; &lt;li&gt; &lt;div style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The default size of the connection pool is 100. If the connection is not closed, size of the orphaned connections in the pool is increased and overflowed.&lt;/font&gt;&lt;/div&gt; &lt;li&gt; &lt;div style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The connection will not automatically add back to the pool when dispose. The connection should be explicitly closed. This behavior is little bit difference with binding concept (Connection might be closed when data source like data reader is bound to data grid).&lt;/font&gt;&lt;/div&gt;&lt;/ul&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Friends, if you can add more points, please comment.&lt;/font&gt; &lt;p&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Max+pool+size+was+reached%3a+It+happened+again&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!226.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!226.entry</guid><pubDate>Fri, 24 Jun 2005 01:31:54 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!226/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!226.entry#comment</wfw:comment><dcterms:modified>2005-06-24T01:31:54Z</dcterms:modified></item><item><title>Underlining AccessKeys in ASP.NET</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!213.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;How many you guys use “&lt;font color="#660000"&gt;&lt;strong&gt;AccessKey&lt;/strong&gt;&lt;/font&gt;” property of the web controls. I know that most are not using. The reason is, some are still do not know about the property or some do not use it because of its impossibility of setting underline key. It is true that though we can set the “AccessKey” of the control, we can’t show it to user unless we set either tool-tip or text with it.&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Button1.AccessKey = &amp;quot;C&amp;quot;;&lt;br&gt;Button1.Text = &amp;quot;Click&amp;quot;;&lt;br&gt;Button1.ToolTip = &amp;quot;Click Alt+C to access this button&amp;quot;;&lt;br&gt;&lt;font color="#009900"&gt;//Button1.Text = &amp;quot;Click Alt+C to access this button&amp;quot;;&lt;/font&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The workaround for above problem is, use Html Button instead of ASP.NET button. By making the button as server control, we can do the same we do with ASP.NET. In addition to that, we can underline the access key.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;/font&gt;&lt;font color="#990000"&gt;button &lt;/font&gt;&lt;font color="#cc0000"&gt;accesskey&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;C&amp;quot;&lt;/font&gt; &lt;font color="#cc0000"&gt;runat&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/font&gt; &lt;font color="#cc0000"&gt;id&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;HtmlTestButton&amp;quot;&lt;/font&gt; &lt;br&gt;   &lt;font color="#cc0033"&gt;type&lt;/font&gt;&lt;font color="#0000ff"&gt;=&amp;quot;button&amp;quot;&lt;/font&gt; &lt;font color="#0000ff"&gt;&amp;gt;&amp;lt;&lt;/font&gt;&lt;font color="#990000"&gt;U&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;C&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#990000"&gt;U&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;lick&lt;font color="#0000ff"&gt;&amp;lt;/&lt;/font&gt;&lt;font color="#990000"&gt;button&lt;/font&gt;&lt;font color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt; &lt;p&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;By double clicking the button at the design window, Server click procedure can be generated or else we can use &lt;font color="#cc0000"&gt;onserverclick &lt;/font&gt;attribute to handle the click event.&lt;br&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt; &lt;/font&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Underlining+AccessKeys+in+ASP.NET&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!213.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!213.entry</guid><pubDate>Mon, 06 Jun 2005 04:46:20 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!213/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!213.entry#comment</wfw:comment><dcterms:modified>2005-06-06T04:46:20Z</dcterms:modified></item><item><title>Accessing parent window via Popup window</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!211.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;We had been trying to access the parent window's objects via a popup but ended up with failure. Yesterday I just wanted to test this again and, so, I created a small web application and tested. &lt;img height=19 src="http://spaces.msn.com/mmm2005-05-13_18.25/RTE/emoticons/smile_regular.gif" width=19&gt; Haha, found the mistake we have made. We have been trying with &amp;quot;&lt;strong&gt;parent&lt;/strong&gt;&amp;quot; object instead of &amp;quot;&lt;strong&gt;opener&lt;/strong&gt;&amp;quot;. Anyway, I am really happy with it because this had caused lot of problems and had led us to find workarounds. If interest, here is the code.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;em&gt;Javascript in the WebForm1.aspx (form id is TestForm1) that opens WebForm2.aspx&lt;/em&gt;.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#660000" size=1&gt;window.open(&amp;quot;WebForm2.aspx&amp;quot;);&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;em&gt;Javascript in the WebForm2.aspx that accesses the value of the TextBox1 of WebForm1.aspx (parent).&lt;/em&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#660000" size=1&gt;alert(opener.TestForm1.TextBox1.value);&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;So, do not use &amp;quot;parent&amp;quot; instead of &amp;quot;operner&amp;quot;.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Accessing+parent+window+via+Popup+window&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!211.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!211.entry</guid><pubDate>Sat, 04 Jun 2005 02:34:12 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!211/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!211.entry#comment</wfw:comment><dcterms:modified>2005-06-04T02:34:12Z</dcterms:modified></item><item><title>Accelerate your coding speed with VS IDE Macro</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!207.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Have you ever used &lt;strong&gt;&lt;font color="#660000"&gt;macro &lt;/font&gt;&lt;/strong&gt;with your VS IDE? If not, it is high time to use. So, how do we accelerate our coding speed with macro? In ASP.NET applications, one of the common statements is connection instantiation. If the connection string is stored in the web.config file, statement is similar to;&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;SqlConnection sqlConnection = &lt;font color="#0000ff"&gt;new &lt;/font&gt;SqlConnection(System.Configuration.ConfigurationSettings.AppSettings[&amp;quot;ConnectionString&amp;quot;]);&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;We need to write this statement every time needs to make a connection. How if this can automatically be written by single mouse click? Yes, we can. Simply create a macro that writes the statement to the active class. That's how the acceleration works. You can open the Macro explorer by clicking &lt;strong&gt;&lt;em&gt;Alt+F8 &lt;/em&gt;&lt;/strong&gt;or &lt;strong&gt;&lt;em&gt;Tools-&amp;gt;Macros-&amp;gt;Macro Explorer &lt;/em&gt;&lt;/strong&gt;menu. With that explorer, you can have your own module with new macros or can write macros in existing modules. But the worst case of this is, Macro IDE only support VB.NET (I usually don't code with VB.NET). Anyway I use couple of macros because it really makes our life easy. Here is one of the macros I heavily use. This is called &amp;quot;CreateCollectionClass&amp;quot; that creates a strongly-typed collection class for given name. For an example, if you need to have class called &amp;quot;EmployeeCollection&amp;quot; that derives from CollectionBase and implement Add, Remove and this methods, simply you have to run the macro by giving name as Employee. Here is the code for the macro.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;Sub &lt;/font&gt;CreateCollectionClass()&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;   Dim &lt;/font&gt;className &lt;font color="#0000ff"&gt;As String&lt;/font&gt;&lt;br&gt;   className = InputBox(&amp;quot;Enter the class name&amp;quot;)&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;   &lt;/font&gt;If &lt;/font&gt;(className &amp;lt;&amp;gt; &amp;quot;&amp;quot;) &lt;font color="#0000ff"&gt;Then&lt;/font&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;      DTE.ItemOperations.AddNewItem(&amp;quot;Local Project Items\Class&amp;quot;, className &amp;amp; &amp;quot;Collection.cs&amp;quot;)&lt;br&gt;      DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn)&lt;br&gt;      DTE.ActiveDocument.Selection.PageUp(&lt;font color="#0000ff"&gt;False&lt;/font&gt;, 5)&lt;br&gt;      DTE.ActiveDocument.Selection.EndOfLine()&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;using System.Collections;&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.LineDown(&lt;font color="#0000ff"&gt;False&lt;/font&gt;, 7)&lt;br&gt;      DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)&lt;br&gt;      DTE.ActiveDocument.Selection.EndOfLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot; : CollectionBase&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.PageDown(&lt;font color="#0000ff"&gt;False&lt;/font&gt;, 5)&lt;br&gt;      DTE.ActiveDocument.Selection.LineUp(&lt;font color="#0000ff"&gt;False&lt;/font&gt;, 3)&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine(2)&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;public void Add(&amp;quot; &amp;amp; className &amp;amp; &amp;quot; &amp;quot; &amp;amp; LCase(className) &amp;amp; &amp;quot;)&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;{&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;List.Add(&amp;quot; &amp;amp; LCase(className) &amp;amp; &amp;quot;);&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;}&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine(2)&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;public void Remove(&amp;quot; &amp;amp; className &amp;amp; &amp;quot; &amp;quot; &amp;amp; LCase(className) &amp;amp; &amp;quot;)&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;{&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;if (List.Contains(&amp;quot; &amp;amp; LCase(className) &amp;amp; &amp;quot;))&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;List.Remove(&amp;quot; &amp;amp; LCase(className) &amp;amp; &amp;quot;);&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;}&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine(2)&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;public &amp;quot; &amp;amp; className &amp;amp; &amp;quot; this [int index]&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;{&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;get&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;{&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;if (index &amp;gt;= 0 &amp;amp;&amp;amp; index &amp;lt; List.Count)&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;return (&amp;quot; &amp;amp; className &amp;amp; &amp;quot;) List[index];&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;else&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;return null;&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;}&amp;quot;&lt;br&gt;      DTE.ActiveDocument.Selection.NewLine()&lt;br&gt;      DTE.ActiveDocument.Selection.Text = &amp;quot;}&amp;quot;&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;   &lt;/font&gt;&lt;font face=Verdana size=1&gt;End If&lt;br&gt;End Sub&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;When you run (double click on the macro created) the macro by giving a name as &amp;quot;Employee&amp;quot;, will create a class called EmployeeCollection like below.&lt;/font&gt; &lt;p&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;using &lt;/font&gt;System;&lt;br&gt;&lt;font color="#0000ff"&gt;using &lt;/font&gt;System.Collections;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;namespace &lt;/font&gt;yournamesapce&lt;br&gt;{&lt;br&gt;   /// &amp;lt;summary&amp;gt;&lt;br&gt;   /// Summary description for EmployeeCollection.&lt;br&gt;   /// &amp;lt;/summary&amp;gt;&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;   &lt;/font&gt;public class &lt;/font&gt;EmployeeCollection : CollectionBase&lt;br&gt;   {&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;      &lt;/font&gt;public &lt;/font&gt;EmployeeCollection()&lt;br&gt;      {&lt;br&gt;         //&lt;br&gt;         // TODO: Add constructor logic here&lt;br&gt;         //&lt;br&gt;      }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;      &lt;/font&gt;public void &lt;/font&gt;Add(Employee employee)&lt;br&gt;      {&lt;br&gt;         List.Add(employee);&lt;br&gt;      }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;      &lt;/font&gt;public void &lt;/font&gt;Remove(Employee employee)&lt;br&gt;      {&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;         &lt;/font&gt;if &lt;/font&gt;(List.Contains(employee))&lt;br&gt;            List.Remove(employee);&lt;br&gt;      }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;      &lt;/font&gt;public &lt;/font&gt;Employee &lt;font color="#0000ff"&gt;this &lt;/font&gt;[&lt;font color="#0000ff"&gt;int &lt;/font&gt;index]&lt;br&gt;      {&lt;br&gt;         get&lt;br&gt;         {&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;            &lt;/font&gt;if &lt;/font&gt;(index &amp;gt;= 0 &amp;amp;&amp;amp; index &amp;lt; List.Count)&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;               &lt;/font&gt;return &lt;/font&gt;(Employee) List[index];&lt;br&gt;&lt;font color="#0000ff"&gt;&lt;font color="#000000"&gt;            &lt;/font&gt;else&lt;br&gt;&lt;font color="#000000"&gt;               &lt;/font&gt;return null&lt;/font&gt;;&lt;br&gt;         }&lt;br&gt;      }&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;See how easy is this. Writing macro is not much difficult because you can record what you do and save it as macro. You can make changes to the save file as you want too. &lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#660000" size=1&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#660000" size=1&gt;&lt;strong&gt;Assign shortcut key to the macro&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This is also verys simple. Open the keybord category in the Environment in the option dialog box (Tools-&amp;gt;Options menu). Serach the desired macro and assign a short-cut key. Make sure the key is marked as &amp;quot;global&amp;quot; and is not used for anything.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;So, don't wait, accelerate your coding speed.&lt;/font&gt; &lt;p&gt;&lt;br&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Accelerate+your+coding+speed+with+VS+IDE+Macro&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!207.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!207.entry</guid><pubDate>Sat, 28 May 2005 01:27:05 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!207/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!207.entry#comment</wfw:comment><dcterms:modified>2005-05-28T01:33:21Z</dcterms:modified></item><item><title>Unnoticed menu Items in VS IDE: FullScreen</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!206.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;I wonder why I didn’t use the “FullScreen” mode in VS IDE. By pressing &lt;strong&gt;Shift+Alt+Enter &lt;/strong&gt;keys, “FullScreen” mode can be activated and it really makes the code page clear and wide (of course Full Screen). &lt;em&gt;The moral of the above code is that there are some menu items still remain un-noticed by me&lt;/em&gt;&lt;img height=19 src="http://spaces.msn.com/mmm2005-05-13_18.25/RTE/emoticons/smile_regular.gif" width=19&gt;. Have you gone through all menu items in the VS IDE?&lt;/font&gt; &lt;p&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Unnoticed+menu+Items+in+VS+IDE%3a+FullScreen&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!206.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!206.entry</guid><pubDate>Thu, 26 May 2005 16:36:43 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!206/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!206.entry#comment</wfw:comment><dcterms:modified>2005-05-27T03:36:47Z</dcterms:modified></item><item><title>Code of the PerformenceTimer</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!205.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Received couple of requests to share the code of PerformenceTimer. So, here it is. Earlier I used to use Environment.TickCount property for handling timing information but found this code that uses QueryPerformanceCounter  API. The QueryPerformanceCounter function retrieves the current value of the high-resolution performance counter, if one exists. The disadvantages of this are you might get 0 if the installed hardware does not support for high resolution performance counter and might get wrong result in multiprocessor environment. See MSDN for more information. Here is the code.&lt;/font&gt; &lt;p&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public class&lt;/font&gt; PerformenceTimer&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;private long &lt;/font&gt;_startTime;&lt;br&gt;   &lt;font color="#0000ff"&gt;private long &lt;/font&gt;_endTime;&lt;br&gt;   &lt;font color="#0000ff"&gt;private long &lt;/font&gt;_frequency;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   [DllImport(&amp;quot;Kernel32.dll&amp;quot;)]&lt;br&gt;   &lt;font color="#0000ff"&gt;private static extern bool &lt;/font&gt;QueryPerformanceCounter(&lt;font color="#0000ff"&gt;out long &lt;/font&gt;lpPerformanceCount);&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   [DllImport(&amp;quot;Kernel32.dll&amp;quot;)]&lt;br&gt;   &lt;font color="#0000ff"&gt;private static extern bool &lt;/font&gt;QueryPerformanceFrequency(&lt;font color="#0000ff"&gt;out long &lt;/font&gt;lpFrequency);&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public &lt;/font&gt;PerformenceTimer()&lt;br&gt;   {&lt;br&gt;       _startTime = 0;&lt;br&gt;       _endTime = 0;&lt;br&gt; &lt;br&gt;       &lt;font color="#0000ff"&gt;if &lt;/font&gt;(QueryPerformanceFrequency(&lt;font color="#0000ff"&gt;out &lt;/font&gt;_frequency) == &lt;font color="#0000ff"&gt;false&lt;/font&gt;)&lt;br&gt;       {&lt;br&gt;           &lt;font color="#339900"&gt;//highperformence counter is not supported&lt;/font&gt;&lt;br&gt;          &lt;font color="#0000ff"&gt; throw new &lt;/font&gt;System.ComponentModel.Win32Exception();&lt;br&gt;       }&lt;br&gt;   }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public void &lt;/font&gt;Start()&lt;br&gt;   {&lt;br&gt;       QueryPerformanceCounter(&lt;font color="#0000ff"&gt;out &lt;/font&gt;_startTime);&lt;br&gt;   }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public void &lt;/font&gt;Stop()&lt;br&gt;   {&lt;br&gt;       QueryPerformanceCounter(&lt;font color="#0000ff"&gt;out &lt;/font&gt;_endTime);&lt;br&gt;   }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public void &lt;/font&gt;Reset()&lt;br&gt;   {&lt;br&gt;       _startTime = 0;&lt;br&gt;       _endTime = 0;&lt;br&gt;   }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public double &lt;/font&gt;ElapsedSeconds {&lt;font color="#0000ff"&gt;get &lt;/font&gt;{&lt;font color="#0000ff"&gt;return &lt;/font&gt;(&lt;font color="#0000ff"&gt;double&lt;/font&gt;)(_endTime - _startTime) / (&lt;font color="#0000ff"&gt;double&lt;/font&gt;)_frequency;}}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;}&lt;/font&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Code+of+the+PerformenceTimer&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!205.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!205.entry</guid><pubDate>Thu, 26 May 2005 00:53:15 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!205/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!205.entry#comment</wfw:comment><dcterms:modified>2005-05-26T10:31:26Z</dcterms:modified></item><item><title>Does string always create a new instance when it is changed?</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!203.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;My answer would be &amp;quot;yes&amp;quot; if someone ask me before but now my answer is &amp;quot;no&amp;quot;. As we know, strings are immutable and will create new strings on the heap when it is changed. But this scenario does not always apply. Especially with literal string, if the values of two strings are same, heap has only one string object but referenced by two variables.&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;myString1 = &amp;quot;dinesh priyankara&amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;myString2 = &amp;quot;dinesh &amp;quot; + &amp;quot;priyankara&amp;quot;;&lt;br&gt;Console.WriteLine(&amp;quot;myString1 and myString2 have same reference: {0}&amp;quot;, Object.ReferenceEquals(myString1, myString2));&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;&lt;em&gt;myString1 and myString2 have same reference: True&lt;/em&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This is how literal strings are managed. Internally all literal strings are stored in a table called intern pool and check the existence when new literal is added. If the same is exist, new string will not be created on the heap but referenced to existing one. But this is not the case with non-literal.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;myString3 = &amp;quot;dinesh&amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;myString4 = &amp;quot;priyankara&amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;myString5 = myString3 + &amp;quot; &amp;quot; + myString4;&lt;br&gt;Console.WriteLine(&amp;quot;myString1 and myString5 have same reference: {0}&amp;quot;, Object.ReferenceEquals(myString1, myString5));&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;Output&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;&lt;em&gt;myString1 and myString5 have same reference: False&lt;/em&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Though both myString1 and myString5 has same value, new string is created on the heap for myString5. But we can force to have a same object reference by using string.Intern method. This method will return the reference if one exists with same value else will add to the pool and return the new reference.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#009900"&gt;&lt;/font&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#009900"&gt;//string myString5 = myString3 + &amp;quot; &amp;quot; + myString4;&lt;br&gt;&lt;/font&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;myString5 = &lt;font color="#0000ff"&gt;string&lt;/font&gt;.Intern(myString3 + &amp;quot; &amp;quot; + myString4);&lt;br&gt;Console.WriteLine(&amp;quot;myString1 and myString5 have same reference: {0}&amp;quot;, Object.ReferenceEquals(myString1, myString5));&lt;br&gt; &lt;br&gt;&lt;em&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;myString1 and myString5 have same reference: True&lt;/em&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Now both myString1 and myString5 are referenced to the same object in the heap. If interest, read MSDN for more info.&lt;br&gt;&lt;/font&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Does+string+always+create+a+new+instance+when+it+is+changed%3f&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!203.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!203.entry</guid><pubDate>Sun, 22 May 2005 01:53:35 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!203/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!203.entry#comment</wfw:comment><dcterms:modified>2005-05-26T10:32:51Z</dcterms:modified></item><item><title>Concatenation with Response.Write</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!194.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This is very simple thing but important. If we have couple of strings to be written out, what we were (I was) used to do is, concatenating strings and output with single Response.Write call. But this is not the way if we consider about performance and have heavy concatenation. I found this statement while reading some points regarding ASP.NET; &amp;quot;&lt;strong&gt;&lt;font color="#660000"&gt;using multiple Response.Write is faster than concatenation with single call&lt;/font&gt;&lt;/strong&gt;&amp;quot;. The code below is the test I did myself.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#00cc00" size=1&gt;//string out with single call&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string1 = &amp;quot;string 1 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string2 = &amp;quot;string 2 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string3 = &amp;quot;string 3 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string4 = &amp;quot;string 4 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string5 = &amp;quot;string 5 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string6 = &amp;quot;string 6 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string7 = &amp;quot;string 7 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string8 = &amp;quot;string 8 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string9 = &amp;quot;string 9 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string10 = &amp;quot;string 10 &amp;quot;;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;PerformenceTimer.PerformenceTimer timer = &lt;font color="#0000ff"&gt;new &lt;/font&gt;PerformenceTimer.PerformenceTimer();&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;timer.Start();&lt;br&gt;Response.Write(&amp;quot;concatenation &amp;quot;+string1+string2+string3+string4+string5+string6+string7+string8+string9+string10);&lt;br&gt;timer.Stop();&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Response.Write(&amp;quot;&amp;lt;br&amp;gt;&amp;quot;);&lt;br&gt;Response.Write(&amp;quot;Time elapsed: &amp;quot;);&lt;br&gt;Response.Write(timer.ElapsedSeconds.ToString(&amp;quot;N&amp;quot;, numberFormatInfo));&lt;/font&gt; &lt;p&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;output&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;concatenation string 1 string 2 string 3 string 4 string 5 string 6 string 7 string 8 string 9 string 10 &lt;br&gt;Time elapsed: 0.0000064254&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;ran the application several times and the time elapsed around .0000060000 - .0000070000.&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;br&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" color="#00cc00" size=1&gt;//string out with multiple calls&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string1 = &amp;quot;string 1 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string2 = &amp;quot;string 2 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string3 = &amp;quot;string 3 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string4 = &amp;quot;string 4 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string5 = &amp;quot;string 5 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string6 = &amp;quot;string 6 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string7 = &amp;quot;string 7 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string8 = &amp;quot;string 8 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string9 = &amp;quot;string 9 &amp;quot;;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;string10 = &amp;quot;string 10 &amp;quot;;&lt;/font&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;PerformenceTimer.PerformenceTimer timer = &lt;font color="#0000ff"&gt;new &lt;/font&gt;PerformenceTimer.PerformenceTimer();&lt;/font&gt; &lt;p&gt;timer.Start();&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Response.Write(&amp;quot;non concatenation &amp;quot;);&lt;br&gt;Response.Write(string1);&lt;br&gt;Response.Write(string2);&lt;br&gt;Response.Write(string3);&lt;br&gt;Response.Write(string4);&lt;br&gt;Response.Write(string5);&lt;br&gt;Response.Write(string6);&lt;br&gt;Response.Write(string7);&lt;br&gt;Response.Write(string8);&lt;br&gt;Response.Write(string9);&lt;br&gt;Response.Write(string10);&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;timer.Stop();&lt;br&gt;Response.Write(&amp;quot;&amp;lt;br&amp;gt;&amp;quot;);&lt;br&gt;Response.Write(&amp;quot;Time elapsed: &amp;quot;);&lt;br&gt;Response.Write(timer.ElapsedSeconds.ToString(&amp;quot;N&amp;quot;, numberFormatInfo));&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;output&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;non concatenation string 1 string 2 string 3 string 4 string 5 string 6 string 7 string 8 string 9 string 10 &lt;br&gt;Time elapsed: 0.0000044698&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;did the same times and the time elapsed around .0000040000 - .0000045000.&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;so, there is a big difference. We will not see the difference if few strings need to be handled but better add this way to best practices.&lt;/font&gt; &lt;p&gt;&lt;font face=Verdana size=1&gt;&lt;/font&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Concatenation+with+Response.Write&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!194.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!194.entry</guid><pubDate>Fri, 20 May 2005 01:11:00 GMT</pubDate><slash:comments>2</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!194/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!194.entry#comment</wfw:comment><dcterms:modified>2005-05-20T01:11:00Z</dcterms:modified></item><item><title>Accessing .NET assembly through DTS</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!192.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This was terrible because it kept me awake whole night. Yesterday I wanted to access a function I have written with c#.net through SQL Server DTS. So, simply, registered the assembly in the register by using &amp;quot;&lt;em&gt;&lt;strong&gt;regasm.exe&lt;/strong&gt;&lt;/em&gt;&amp;quot; and tried to access it but failed. As I was at the customer site, couldn't do thorough search on the web but went through many sites and studied samples given at the night. Finally I found the problem: &lt;strong&gt;&lt;font color="#660000"&gt;the &amp;quot;/codebase&amp;quot; argument is NOT used that specify the path of the assembly if it is not installed in the GAC.&lt;/font&gt;&lt;/strong&gt; I know, it is a silly mistake but made it. So, thought to blog it.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This is my test class.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;namespace &lt;/font&gt;DotNetClassLibrary&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;public class &lt;/font&gt;TestClass&lt;br&gt;   {&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public &lt;/font&gt;TestClass()&lt;br&gt;   {&lt;br&gt;   }&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;   &lt;font color="#0000ff"&gt;public void &lt;/font&gt;TestMethod(&lt;font color="#0000ff"&gt;string &lt;/font&gt;fileName, &lt;font color="#0000ff"&gt;string &lt;/font&gt;message)&lt;br&gt;   {&lt;br&gt;      StreamWriter streamWriter = File.AppendText(fileName);&lt;br&gt;      streamWriter.WriteLine(message + &amp;quot;: &amp;quot; + DateTime.Now.ToString());&lt;br&gt;      streamWriter.Flush();&lt;br&gt;      streamWriter.Close();&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This should be signed with strongly-name. So, created a &amp;quot;&lt;strong&gt;&lt;font color="#660000"&gt;snk&lt;/font&gt;&lt;/strong&gt;&amp;quot; file with &amp;quot;&lt;strong&gt;&lt;font color="#660000"&gt;sn.exe&lt;/font&gt;&lt;/strong&gt;&amp;quot; and placed to the project folder.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;[assembly: AssemblyKeyFile(&amp;quot;..\\key.snk&amp;quot;)]&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Copied the dll to the folder called &amp;quot;DotNetLibraries&amp;quot; and registered the assembly.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;E:\ DotNetLibraries&amp;gt;regasm.exe &lt;em&gt;DotNetClassLibrary.dll /tlb: DotNetClassLibrary.tlb /codebase&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Done! Now this can be simply accessed by the ActiveX task in the DTS.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Function Main()&lt;br&gt;&lt;em&gt; dim dotnetobject&lt;br&gt; set dotnetobject = createobject(&amp;quot;DotNetClassLibrary.TestClass&amp;quot;)&lt;br&gt; dotnetobject.TestMethod &amp;quot;E:\\Result\\Test1.txt&amp;quot;, &amp;quot;this is test&amp;quot;&lt;br&gt; Main = DTSTaskExecResult_Success&lt;/em&gt;&lt;br&gt;End Function&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;But still one problem remains. Though it can be un-registered, seems it didn't completely remove. Again went through some blogs and found couple of good posts (&lt;a href="http://blogs.borland.com/cbensen/archive/2004/12/08/2111.aspx"&gt;This has something good&lt;/a&gt;). Tonight, I have to find the second mistake I have done.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Accessing+.NET+assembly+through+DTS&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!192.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!192.entry</guid><pubDate>Fri, 13 May 2005 01:15:13 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!192/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!192.entry#comment</wfw:comment><dcterms:modified>2005-05-13T01:15:13Z</dcterms:modified></item><item><title>The beauty of "readonly"</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!189.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;I had a class library that has couple of constant fields that was used in one of my freelance application. Recently, my client wanted to make some changes for the application and, yes it caused to change the class library. So, changed values of some const fields and uploaded the dll of the library. Guess what? New values of const fields are NOT applied. What was the problem? So, made some searches, and found something I was unaware (I should have known this). &amp;quot;&lt;strong&gt;&lt;font color="#660033"&gt;All the const fields are replaced to its value when the application is compiled&lt;/font&gt;&lt;/strong&gt;.&amp;quot; Though I have built the library and replaced, as the main application is not compiled again, it still has the old value. So, then I rebuilt the application and fixed the problem. And I found another thing, if I had used &amp;quot;&lt;strong&gt;static readonly&lt;/strong&gt;&amp;quot;, the application is NOT needed to be recompiled. To test and make sure, I wrote a simple application. Here it is.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This is the class in the library with const field&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;namespace &lt;/font&gt;ClassWithConstant&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;public class &lt;/font&gt;Class1&lt;br&gt;   {&lt;br&gt;      &lt;font color="#0000ff"&gt;public const int &lt;/font&gt;constInteger = 150;&lt;br&gt;      &lt;font color="#0000ff"&gt;public&lt;/font&gt; Class1() {}&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;This is the class in another library with static readonly field&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;namespace &lt;/font&gt;ClassWithReadOnly&lt;br&gt;{&lt;br&gt;  &lt;font color="#0000ff"&gt; public class &lt;/font&gt;Class1&lt;br&gt;   {&lt;br&gt;      &lt;font color="#0000ff"&gt;public static readonly int &lt;/font&gt;readOnlyInteger = 250;&lt;br&gt;      &lt;font color="#0000ff"&gt;public &lt;/font&gt;Class1(){}&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Code in my main application that has references for both above classes (dlls)&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;[STAThread]&lt;br&gt;&lt;font color="#0000ff"&gt;static void &lt;/font&gt;Main(&lt;font color="#0000ff"&gt;string&lt;/font&gt;[] args)&lt;br&gt;{&lt;br&gt;   Console.WriteLine(&amp;quot;Value of const of referenced class: {0}&amp;quot;, ClassWithConstant.Class1.constInteger);&lt;br&gt;   Console.WriteLine(&amp;quot;Value of readonly of referenced class: {0}&amp;quot;, ClassWithReadOnly.Class1.readOnlyInteger);&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Then placed the release of the main application to the different location. Here is the output of release.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;Value of const of referenced class: 150&lt;br&gt;Value of const of referenced class: 250&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;After that, changed the code of the both classes in the both libraries and just replaced the &amp;quot;dll&amp;quot; in the new location. Now, here is the new output.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;public const int &lt;/font&gt;constInteger = 1500;&lt;br&gt;&lt;font color="#0000ff"&gt;public static readonly int &lt;/font&gt;readOnlyInteger = 2500;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;strong&gt;&lt;em&gt;Value of const of referenced class: 150&lt;br&gt;Value of const of referenced class: 2500&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;See, still the const filed has old value but static readonly. You can get some good points from &lt;/font&gt;&lt;a href="http://community.sgdotnet.org/blogs/triplez/archive/2005/04/14/13768.aspx" target="_blank"&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;http://community.sgdotnet.org/blogs/triplez/archive/2005/04/14/13768.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p&gt;&lt;br&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+The+beauty+of+%22readonly%22&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!189.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!189.entry</guid><pubDate>Thu, 12 May 2005 01:40:43 GMT</pubDate><slash:comments>2</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!189/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!189.entry#comment</wfw:comment><dcterms:modified>2005-05-12T01:40:43Z</dcterms:modified></item><item><title>IsNumeric with c#.net</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!188.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Couple of months ago, I found a good &amp;quot;VB.NET IsNumeric&amp;quot; equivalent for c#.net while was searching an equivalent. I had an equivalent that implemented with &amp;quot;try&amp;quot; and &amp;quot;catch&amp;quot; blocks but decided to stop that way and stick into new way. So, thought to share it.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#009900"&gt;//my old way&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;public static bool &lt;/font&gt;IsNumeric(&lt;font color="#0000ff"&gt;string &lt;/font&gt;text)&lt;br&gt;{&lt;br&gt;&lt;font color="#0000ff"&gt;   try&lt;/font&gt;&lt;br&gt;   {&lt;br&gt;       &lt;font color="#0000ff"&gt;int &lt;/font&gt;integerValue = Convert.ToInt32(text);&lt;br&gt;   }&lt;br&gt;&lt;font color="#0000ff"&gt;   catch&lt;/font&gt;&lt;br&gt;   {&lt;br&gt;       &lt;font color="#0000ff"&gt;return false&lt;/font&gt;;&lt;br&gt;   }&lt;br&gt;&lt;font color="#0000ff"&gt;   return true&lt;/font&gt;;&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#339900"&gt;//testing&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;text = &amp;quot;sdfds dffds fa45 g68&amp;quot;;&lt;br&gt;PerformenceTimer.PerformenceTimer timer = &lt;font color="#0000ff"&gt;new  &lt;/font&gt;PerformenceTimer.PerformenceTimer();&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;timer.Start();&lt;br&gt;&lt;font color="#0000ff"&gt;bool &lt;/font&gt;isNumeric = Test.IsNumeric(text);&lt;br&gt;timer.Stop();&lt;br&gt;Console.WriteLine(&amp;quot;Is numeric: {0}. Elapsed time: {1}&amp;quot;, isNumeric, timer.ElapsedSeconds);&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;output&lt;br&gt;&lt;strong&gt;&lt;em&gt;Is numeric: False. Elapsed time: 0.0049065&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#339900"&gt;//method now using&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;public static bool &lt;/font&gt;IsNumeric2(string text)&lt;br&gt;{&lt;br&gt;&lt;font color="#0000ff"&gt;   char&lt;/font&gt;[] charArray = text.ToCharArray();&lt;br&gt;&lt;font color="#0000ff"&gt;   for&lt;/font&gt;(&lt;font color="#0000ff"&gt;int &lt;/font&gt;x=0; x&amp;lt;charArray.Length; x++) &lt;br&gt;   { &lt;br&gt;    &lt;font color="#0000ff"&gt;if &lt;/font&gt;(!&lt;font color="#0000ff"&gt;char&lt;/font&gt;.IsDigit(charArray[x]))&lt;br&gt;        &lt;font color="#0000ff"&gt;return false&lt;/font&gt;;&lt;br&gt;   }&lt;br&gt;&lt;font color="#0000ff"&gt;   return true&lt;/font&gt;;&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#339900"&gt;//testing&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;string &lt;/font&gt;text = &amp;quot;sdfds dffds fa45 g68&amp;quot;;&lt;br&gt;PerformenceTimer.PerformenceTimer timer = &lt;font color="#0000ff"&gt;new  &lt;/font&gt;PerformenceTimer.PerformenceTimer();&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;timer.Start();&lt;br&gt;&lt;font color="#0000ff"&gt;bool &lt;/font&gt;isNumeric = Test.IsNumeric(text);&lt;br&gt;timer.Stop();&lt;br&gt;Console.WriteLine(&amp;quot;Is numeric: {0}. Elapsed time: {1}&amp;quot;, isNumeric, timer.ElapsedSeconds);&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;output&lt;br&gt;&lt;strong&gt;&lt;em&gt;Is numeric: False. Elapsed time: 0.0013188&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+IsNumeric+with+c%23.net&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!188.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!188.entry</guid><pubDate>Wed, 11 May 2005 01:00:26 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!188/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!188.entry#comment</wfw:comment><dcterms:modified>2005-05-11T01:00:26Z</dcterms:modified></item><item><title>The “ref” and “out” modifiers in method arguments</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!168.entry</link><description>&lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;I was asked by one of my friends that what’s different by passing values as “&lt;strong&gt;&lt;font color="#990000"&gt;ref&lt;/font&gt;&lt;/strong&gt;” and “&lt;strong&gt;&lt;font color="#990000"&gt;out&lt;/font&gt;&lt;/strong&gt;” if both are passed “by reference”. At once I couldn’t answer but said that with “out” modifier, parameters can be passed &lt;em&gt;un-initialized&lt;/em&gt;. Anyway, thought I’d better brush up my knowledge, did a small code.&lt;/font&gt; &lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#339933"&gt;//This method accepts two paras, one as ref and one as out&lt;/font&gt;&lt;br&gt;&lt;font color="#0000ff"&gt;public void &lt;/font&gt;Method01 (&lt;font color="#0000ff"&gt;ref int &lt;/font&gt;y, &lt;font color="#0000ff"&gt;out int &lt;/font&gt;z)&lt;br&gt;{&lt;br&gt;    y++;&lt;br&gt;    z = 3;&lt;br&gt;}&lt;/font&gt; &lt;p style=""&gt;  &lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;font color="#0000ff"&gt;int &lt;/font&gt;y = 2;&lt;br&gt;&lt;font color="#0000ff"&gt;int &lt;/font&gt;z;&lt;/font&gt; &lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;MyMethod(&lt;font color="#0000ff"&gt;ref &lt;/font&gt;y, &lt;font color="#0000ff"&gt;out &lt;/font&gt;z);&lt;/font&gt; &lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;&lt;/font&gt;  &lt;p style=""&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;The z variable is not &lt;em&gt;initialized &lt;/em&gt;but can be passed to the method. But a value must be assigned to z within the method. And y must be assigned before passing it to method. &lt;/font&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+The+%e2%80%9cref%e2%80%9d+and+%e2%80%9cout%e2%80%9d+modifiers+in+method+arguments&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!168.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!168.entry</guid><pubDate>Fri, 06 May 2005 01:45:14 GMT</pubDate><slash:comments>4</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!168/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!168.entry#comment</wfw:comment><dcterms:modified>2005-05-06T01:45:14Z</dcterms:modified></item><item><title>SortedList: The "Hybrid" between a Hashtable and an  Array</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!167.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Though I was aware about &lt;strong&gt;&lt;font color="#660000"&gt;SortedList&lt;/font&gt;&lt;/strong&gt;, I have never ever used it (Or I was unaware of its benifts) for coding. But today it really helped me because I had a dictionary type collection that needed to be sorted by its key. Because the elements in the SortedList are autometically sorted by its key and values can be accessed through both index and key, it really cut down some my heavy work load.&lt;/font&gt; &lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Some key points about SortedList&lt;/font&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Does not allow duplicate keys.&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;IComparer/IComparable can be implemented for sorting instead of default.&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;Might decrease performance as need to re-organize for every inserting and removing.&lt;/font&gt;&lt;/ul&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+SortedList%3a+The+%22Hybrid%22+between+a+Hashtable+and+an++Array&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!167.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!167.entry</guid><pubDate>Wed, 04 May 2005 19:20:43 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!167/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!167.entry#comment</wfw:comment><dcterms:modified>2005-05-04T19:22:53Z</dcterms:modified></item><item><title>Sorting values by size in ArrayList</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!166.entry</link><description>&lt;p&gt;&lt;font face="Verdana, Geneva, Arial, Sans-serif" size=1&gt;One of my colleagues came and asked me some best ways to sort elements (string type) by size in an ArrayList. Obviously, there are couple of ways to do the sort (he had some in his mind too) but needed to make it simple. So, I asked him to have a Comparer class that do the compare base on the size and use it for &amp;quot;Sort&amp;quot; method. And it worked……Here is the code.&lt;/font&gt; &lt;p&gt;&lt;font size=1&gt;&lt;font color="#0000ff"&gt;public class &lt;/font&gt;LengthComparer : IComparer&lt;br&gt;{&lt;br&gt;   &lt;font color="#0000ff"&gt;public int &lt;/font&gt;Compare(&lt;font color="#0000cc"&gt;object &lt;/font&gt;x, &lt;font color="#0000ff"&gt;object &lt;/font&gt;y)&lt;br&gt;   {&lt;br&gt;       &lt;font color="#0000ff"&gt;return &lt;/font&gt;(&lt;font color="#0000ff"&gt;new &lt;/font&gt;CaseInsensitiveComparer().Compare(y.ToString().Length, x.ToString().Length));&lt;br&gt;   }&lt;br&gt;}&lt;/font&gt; &lt;p&gt;&lt;font size=1&gt;ArrayList arrayList = &lt;font color="#0000ff"&gt;new &lt;/font&gt;ArrayList();&lt;br&gt;arrayList.Add(&amp;quot;lmn&amp;quot;);&lt;br&gt;arrayList.Add(&amp;quot;abcde&amp;quot;);&lt;br&gt;arrayList.Add(&amp;quot;wxyz&amp;quot;);&lt;/font&gt; &lt;p&gt;&lt;font size=1&gt;arrayList.Sort(new LengthComparer());&lt;/font&gt; &lt;p&gt;&lt;font size=1&gt;&lt;/font&gt; &lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4683496953178731031&amp;page=RSS%3a+Sorting+values+by+size+in+ArrayList&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=dineshpriyankara.spaces.live.com&amp;amp;GT1=dineshpriyankara"&gt;</description><comments>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!166.entry#comment</comments><guid isPermaLink="true">http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!166.entry</guid><pubDate>Wed, 04 May 2005 19:14:00 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://dineshpriyankara.spaces.live.com/blog/cns!40FF1FAA28D7B217!166/comments/feed.rss</wfw:commentRss><wfw:comment>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!166.entry#comment</wfw:comment><dcterms:modified>2005-05-04T19:14:00Z</dcterms:modified></item><item><title>Ooops! Maximum URL length is exceeded.</title><link>http://dineshpriyankara.spaces.live.com/Blog/cns!40FF1FAA28D7B217!162.entry</link