<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.fuzzydev.com/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>.Net : C#</title><link>http://www.fuzzydev.com/blogs/dotnet/archive/category/1001.aspx</link><description /><dc:language>en-US</dc:language><generator>CommunityServer 2.0 (Build: 60404.2676)</generator><item><title>Tech.Ed 2006 - for geeks in Chennai</title><link>http://www.fuzzydev.com/blogs/dotnet/archive/2006/06/10/TechEd_2006_for_geeks_in_Chennai.aspx</link><pubDate>Sat, 10 Jun 2006 18:13:00 GMT</pubDate><guid isPermaLink="false">daf517d6-b4b1-4612-b76e-1f60975996ca:10</guid><dc:creator>sachinjoshi</dc:creator><slash:comments>1</slash:comments><comments>http://www.fuzzydev.com/blogs/dotnet/comments/10.aspx</comments><wfw:commentRss>http://www.fuzzydev.com/blogs/dotnet/commentrss.aspx?PostID=10</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial&gt;Tech.Ed 2006 in Chennai will be held at Chennai Trade Centre and kick starts on 15th June and will end with a bang(entertainment/party) on 17th June.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;Where is Chennai Trade Centre?&lt;/STRONG&gt;&lt;BR&gt;Chennai Trade Centre&lt;BR&gt;Mount Poonamallee High Road&lt;BR&gt;Nandambakkam &lt;BR&gt;Chennai: 600089 &lt;BR&gt;Ph: 91-44-22316033, 22315551 &lt;BR&gt;&lt;/FONT&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Map of Chennai Trade Centre is available at &lt;A href="http://www.indiasoft.ind.in/venue_map.htm"&gt;http://www.indiasoft.ind.in/venue_map.htm&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Complete details of all the session is available at &lt;A href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032295913&amp;Culture=en-IN"&gt;http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032295913&amp;Culture=en-IN&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Visit &lt;A href="http://forums.techedindia.com/"&gt;http://forums.techedindia.com/&lt;/A&gt; a forum started by MVP's to answer all your developer and IT Pro related questions. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Visit &lt;A href="http://spaces.msn.com/vineetgupta/"&gt;http://spaces.msn.com/vineetgupta/&lt;/A&gt; and know what Vineet Gupta is cooking for the TechEd sessions. He is loaded with and willing to share his wisdom on Data Platform and Architecture tracks.&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://www.fuzzydev.com/aggbug.aspx?PostID=10" width="1" height="1"&gt;</description><category domain="http://www.fuzzydev.com/blogs/dotnet/archive/category/1000.aspx">ASP.Net</category><category domain="http://www.fuzzydev.com/blogs/dotnet/archive/category/1001.aspx">C#</category></item><item><title>String.IsNullOrEmpty(String)</title><link>http://www.fuzzydev.com/blogs/dotnet/archive/2006/06/10/StringIsNullOrEmpty.aspx</link><pubDate>Sat, 10 Jun 2006 09:09:00 GMT</pubDate><guid isPermaLink="false">daf517d6-b4b1-4612-b76e-1f60975996ca:4</guid><dc:creator>sachinjoshi</dc:creator><slash:comments>1</slash:comments><comments>http://www.fuzzydev.com/blogs/dotnet/comments/4.aspx</comments><wfw:commentRss>http://www.fuzzydev.com/blogs/dotnet/commentrss.aspx?PostID=4</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial&gt;As simple as it gets, C# 2.0 has brought with it loads of language features. Some made a huge difference and few less talked about.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;One of them is String's IsNullOrEmpty method, let's do a comparision of C# 1.1 and 2.0 logic to check for a empty and null string. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;We have been doing this past several years, a condition where in we check a string object is null or empty and perform certain actions based on the the outcome of the condition. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;//C# 1.1 Sample code&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;string sParam = null; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;if( (sParam != null) &amp;&amp; (sParam != string.Empty) ) { &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;//Do something &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt; //C# 2.0 Sample code&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;string sParam = null; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;if( string.IsNullOrEmpty(sParam) ) { &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;//Do something &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;} &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Now the difference is pretty clear....same logic but well simplified. Many of you will be wondering why the method IsNullOrEmpty is a static member of string class. Point here is we are checking for null or empty string and if that instance of string is null then it will throw a NullReference exception.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Can the word simply be more simplied? &lt;img src="/emoticons/emotion-5.gif" alt="Wink [;)]" /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://www.fuzzydev.com/aggbug.aspx?PostID=4" width="1" height="1"&gt;</description><category domain="http://www.fuzzydev.com/blogs/dotnet/archive/category/1001.aspx">C#</category></item><item><title>String.Contains(String)</title><link>http://www.fuzzydev.com/blogs/dotnet/archive/2006/06/10/StringContains.aspx</link><pubDate>Sat, 10 Jun 2006 09:07:00 GMT</pubDate><guid isPermaLink="false">daf517d6-b4b1-4612-b76e-1f60975996ca:3</guid><dc:creator>sachinjoshi</dc:creator><slash:comments>3</slash:comments><comments>http://www.fuzzydev.com/blogs/dotnet/comments/3.aspx</comments><wfw:commentRss>http://www.fuzzydev.com/blogs/dotnet/commentrss.aspx?PostID=3</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial&gt;In our .Net 1.1 days we used to check whether a string object contains a specified string(text) using IndexOf method. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Here is the typical code to check the existence of a string in an string object. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;//Sample code&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;string sName = "John Smith"; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;if(sName.IndexOf("Smith") &gt; -1) { &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;//Smith exists in string object sName &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;} &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Now let's take a closer look at the above code...... What we want is to know whether an instance of string contains some string(text). &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Did I say contains......that's exactly C# .Net 2.0 provides us with. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Let's revisit the same functionality using 2.0 &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;//Sample code&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;string sName = "John Smith"; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;if(sName.Contains("Smith")) { &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;//Smith exists in string object sName &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;} &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Wallah.....it's so simple and sophisticated.&lt;/FONT&gt; &lt;/P&gt;&lt;img src="http://www.fuzzydev.com/aggbug.aspx?PostID=3" width="1" height="1"&gt;</description><category domain="http://www.fuzzydev.com/blogs/dotnet/archive/category/1001.aspx">C#</category></item><item><title>System.Nullable A.k.a Nullable types</title><link>http://www.fuzzydev.com/blogs/dotnet/archive/2006/06/09/NullableTypes.aspx</link><pubDate>Fri, 09 Jun 2006 17:10:00 GMT</pubDate><guid isPermaLink="false">daf517d6-b4b1-4612-b76e-1f60975996ca:5</guid><dc:creator>sachinjoshi</dc:creator><slash:comments>0</slash:comments><comments>http://www.fuzzydev.com/blogs/dotnet/comments/5.aspx</comments><wfw:commentRss>http://www.fuzzydev.com/blogs/dotnet/commentrss.aspx?PostID=5</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial&gt;Developers were always looking forward to the inclusion of Nullable types in C#. I love the way it's been implemented using generics. Before we go in to the specifics of Nullable types; let's look at what is a Nullable type and it's usage. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;What's a Nullable type?&lt;/STRONG&gt;&lt;BR&gt;A nullable type is a value type which can be assigned a null value. Type's like int/bool/double/etc... now can be assigned null values. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;Usage:&lt;/STRONG&gt;&lt;BR&gt;A simple case for nullable type is while assigning a database column value to a value type. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;&lt;STRONG&gt;Example:&lt;/STRONG&gt; &lt;BR&gt;int iEmpId = 0; &lt;BR&gt;&lt;STRONG&gt;//Will throw an error if the DataReader value is null&lt;/STRONG&gt;&lt;BR&gt;iEmpId = (int)drEmployee["id"]; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Now let's see how a value type can be promoted to a Nullable type with the magic of generics. &lt;BR&gt;&lt;BR&gt;&lt;STRONG&gt;Declaring a nullable type is straight forward..&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;System.Nullable iEmpId; &lt;BR&gt;or&lt;BR&gt;int? iEmpId; &lt;STRONG&gt;//that's a shorthand &lt;/STRONG&gt;&lt;BR&gt;iEmpId = null; &lt;STRONG&gt;//Allowed as it's Nullable&lt;/STRONG&gt;&lt;BR&gt;if(iEmpId.HasValue){&lt;BR&gt;//do something &lt;BR&gt;} &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;So for assigning a value from let's say a datareader, we could do something like this. &lt;BR&gt;&lt;BR&gt;int? iEmpId = null; &lt;BR&gt;iEmpId = (int?)drEmployee["id"]; &lt;BR&gt;if(iEmpId.HasValue){&lt;BR&gt;//do something&lt;BR&gt;}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Hmm that certainly makes sense, isn't it?&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://www.fuzzydev.com/aggbug.aspx?PostID=5" width="1" height="1"&gt;</description><category domain="http://www.fuzzydev.com/blogs/dotnet/archive/category/1001.aspx">C#</category></item><item><title>Interned string</title><link>http://www.fuzzydev.com/blogs/dotnet/archive/2006/06/09/Interned_string.aspx</link><pubDate>Fri, 09 Jun 2006 09:05:00 GMT</pubDate><guid isPermaLink="false">daf517d6-b4b1-4612-b76e-1f60975996ca:2</guid><dc:creator>sachinjoshi</dc:creator><slash:comments>1</slash:comments><comments>http://www.fuzzydev.com/blogs/dotnet/comments/2.aspx</comments><wfw:commentRss>http://www.fuzzydev.com/blogs/dotnet/commentrss.aspx?PostID=2</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial&gt;Interned string is nothing but a locked up version of a string, so that it can be shared.&lt;/FONT&gt;&lt;/P&gt;&lt;FONT face=Arial&gt;
&lt;P&gt;Memory allocation can be avoided by using string.Empty.&lt;/P&gt;
&lt;P&gt;string sFirstName = string.Empty; &lt;/P&gt;
&lt;P&gt;The C# compiler is intelligent enough to generate code based on our declaration, if we declare a string object with either string.Empty it just refers to a shared empty string object. As we know string object are immutable(cannot be changed) once created so any assignment will not affect the shared string object.&lt;/FONT&gt; &lt;/P&gt;&lt;img src="http://www.fuzzydev.com/aggbug.aspx?PostID=2" width="1" height="1"&gt;</description><category domain="http://www.fuzzydev.com/blogs/dotnet/archive/category/1001.aspx">C#</category></item><item><title>Generics an overview</title><link>http://www.fuzzydev.com/blogs/dotnet/archive/2006/06/08/Generics_An_Overview.aspx</link><pubDate>Thu, 08 Jun 2006 15:38:00 GMT</pubDate><guid isPermaLink="false">daf517d6-b4b1-4612-b76e-1f60975996ca:1</guid><dc:creator>sachinjoshi</dc:creator><slash:comments>1</slash:comments><comments>http://www.fuzzydev.com/blogs/dotnet/comments/1.aspx</comments><wfw:commentRss>http://www.fuzzydev.com/blogs/dotnet/commentrss.aspx?PostID=1</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Arial&gt;We all have come across a situation where we need to store a collection of a specific type.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Let's say for example we have a class called Customer and we need to have a collection of customers.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Simple way of doing that may be to use ArrayList and add customer class to it. But we have to pay a heavy price for using an ArrayList.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Arial&gt;For those of you who don't know the pitfalls of using ArrayList, let me briefly list it out.&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Arial&gt;The default initial capacity of an ArrayList is 16, even if you add only 2 items to the ArrayList object it will still occupy memory area of 16 elements.&lt;BR&gt;&lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Arial&gt;Assume you have added 17th element in your ArrayList object then your object will grow to 32 capacity, that's real waste of memory. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Arial&gt;ArrayList stores everything as object and so any value type you store goes through an overhead of boxing and unboxing. Boxing and Unboxing is the most performance intensive operation in .Net as it has to convert a value type to a reference type and the vice versa. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Arial&gt;There is no type safety as you can store any type in an ArrayList object.&lt;/FONT&gt;&lt;BR&gt;&lt;STRONG&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face=Arial&gt;Now where do the Generics come in picture.......??&lt;BR&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/STRONG&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Well they are the saviors in this .Net world, don't believe me then look how simple and smart generics are.&lt;BR&gt;&lt;BR&gt;Now we have a class called Customer and I want a collection of Customer to store n numbers of customers.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt; &lt;STRONG&gt; &lt;FONT face=Arial&gt;//Sample code&lt;/FONT&gt;&lt;BR&gt;&lt;/STRONG&gt; &lt;FONT face=Arial&gt;  objCustomerColl = new List();&lt;BR&gt;&lt;BR&gt;Essentially what we are doing in the above given line of code is we are using the List class which is part of the System.Collections.Generic namespace.&lt;BR&gt;The declaration is pretty simple we are telling the compiler that create a list of Customer class.&lt;BR&gt;&lt;BR&gt;With this simple piece of code we have our CustomerCollection ready for use.&lt;BR&gt;Now we can add, remove and perform many different operations on it.&lt;BR&gt;&lt;BR&gt;  &lt;STRONG&gt;//Sample code&lt;/STRONG&gt;&lt;BR&gt;  objCustomerColl.Add(new Customer());&lt;BR&gt;  Points to be noted....&lt;BR&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;This generic list is type safe.&lt;/FONT&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;FONT face=Arial&gt;If you use a value type to create a generic list it doesn't require boxing/unboxing. &lt;/FONT&gt;
&lt;LI&gt;&lt;FONT face=Arial&gt;All the incrementing/decrementing of the list is done under the hood.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;Few more examples of Generic list....just to give you an idea of how powerfull are generics.&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Arial&gt;List IntCollection = new List();&lt;BR&gt;List StringCollection = new List();&lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://www.fuzzydev.com/aggbug.aspx?PostID=1" width="1" height="1"&gt;</description><category domain="http://www.fuzzydev.com/blogs/dotnet/archive/category/1001.aspx">C#</category></item></channel></rss>