<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: C# string.Empty vs &#8220;&#8221;</title>
	<atom:link href="http://kossovsky.net/index.php/2009/06/string-empty-versus-empty-quotes/feed/" rel="self" type="application/rss+xml" />
	<link>http://kossovsky.net/index.php/2009/06/string-empty-versus-empty-quotes/</link>
	<description>C# Code Snippets, ASP.NET Code Samples, .NET Tips and Tricks</description>
	<lastBuildDate>Mon, 23 Aug 2010 22:58:45 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: ASDF</title>
		<link>http://kossovsky.net/index.php/2009/06/string-empty-versus-empty-quotes/comment-page-1/#comment-4368</link>
		<dc:creator>ASDF</dc:creator>
		<pubDate>Mon, 23 Aug 2010 22:58:45 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=263#comment-4368</guid>
		<description>One interesting thing I observed when compiling with Visual studio.

If a variable is assigned with &quot;&quot; and not used in the code, then VS will throw warning.

If a variable is assigned with string.Empty and not used in the code, then VS will NOT throw warning.

I think &quot;&quot; is helpful to find out unused variables in the application</description>
		<content:encoded><![CDATA[<p>One interesting thing I observed when compiling with Visual studio.</p>
<p>If a variable is assigned with &#8220;&#8221; and not used in the code, then VS will throw warning.</p>
<p>If a variable is assigned with string.Empty and not used in the code, then VS will NOT throw warning.</p>
<p>I think &#8220;&#8221; is helpful to find out unused variables in the application</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Random Links #9 &#124; YASDW - yet another software developer weblog</title>
		<link>http://kossovsky.net/index.php/2009/06/string-empty-versus-empty-quotes/comment-page-1/#comment-68</link>
		<dc:creator>Random Links #9 &#124; YASDW - yet another software developer weblog</dc:creator>
		<pubDate>Mon, 13 Jul 2009 17:01:13 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=263#comment-68</guid>
		<description>[...] C# string.Empty vs “” Interessant, weil ich (mich) das auch schon gefragt habe. Trotzdem ist eigentlich Wurst, Hauptsache konsistent im Projekt. [...]</description>
		<content:encoded><![CDATA[<div style="color:#008200">
<p>[...] C# string.Empty vs “” Interessant, weil ich (mich) das auch schon gefragt habe. Trotzdem ist eigentlich Wurst, Hauptsache konsistent im Projekt. [...]</p>
</div>
]]></content:encoded>
	</item>
	<item>
		<title>By: Xander</title>
		<link>http://kossovsky.net/index.php/2009/06/string-empty-versus-empty-quotes/comment-page-1/#comment-63</link>
		<dc:creator>Xander</dc:creator>
		<pubDate>Mon, 13 Jul 2009 13:10:48 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=263#comment-63</guid>
		<description>&lt;a href=&quot;#comment-62&quot; rel=&quot;nofollow&quot;&gt;@Lasse V. Karlsen &lt;/a&gt; 
This is what i see from IL

empty quotes (&quot;&quot;) Test :
  IL_001c:  ldloc.0
  IL_001d:  ldstr      &quot;&quot;
  IL_0022:  call       bool [mscorlib]System.String::op_Equality(string,string)

string.Empty Test :
  IL_001c:  ldloc.0
  IL_001d:  ldsfld     string [mscorlib]System.String::Empty
  IL_0022:  call       bool [mscorlib]System.String::op_Equality(string,string)

As you can see there is a difference.
&quot;&quot; - represented as &quot;ldstr&quot; - pushes an object reference (type O) to a new string object

string.Empty  - represented as &quot;ldsfld&quot; - pushes the value of a static field on the stack</description>
		<content:encoded><![CDATA[<p><a href="#comment-62" rel="nofollow">@Lasse V. Karlsen </a><br />
This is what i see from IL</p>
<p>empty quotes (&#8220;&#8221;) Test :<br />
  IL_001c:  ldloc.0<br />
  IL_001d:  ldstr      &#8220;&#8221;<br />
  IL_0022:  call       bool [mscorlib]System.String::op_Equality(string,string)</p>
<p>string.Empty Test :<br />
  IL_001c:  ldloc.0<br />
  IL_001d:  ldsfld     string [mscorlib]System.String::Empty<br />
  IL_0022:  call       bool [mscorlib]System.String::op_Equality(string,string)</p>
<p>As you can see there is a difference.<br />
&#8220;&#8221; &#8211; represented as &#8220;ldstr&#8221; &#8211; pushes an object reference (type O) to a new string object</p>
<p>string.Empty  &#8211; represented as &#8220;ldsfld&#8221; &#8211; pushes the value of a static field on the stack</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lasse V. Karlsen</title>
		<link>http://kossovsky.net/index.php/2009/06/string-empty-versus-empty-quotes/comment-page-1/#comment-62</link>
		<dc:creator>Lasse V. Karlsen</dc:creator>
		<pubDate>Mon, 13 Jul 2009 11:51:47 +0000</pubDate>
		<guid isPermaLink="false">http://kossovsky.net/?p=263#comment-62</guid>
		<description>Are you sure there is a difference except your runtime environment in that last test there?

Here&#039;s the two comparisons, disassembled in release-mode:

                if (TestValue == string.Empty)
00000036  mov         edx,dword ptr ds:[022F102Ch] 
0000003c  mov         ecx,dword ptr [ebp-10h] 
0000003f  call        75D95F98 

                if (TestValue == &quot;&quot;)
00000059  mov         edx,dword ptr ds:[022F202Ch] 
0000005f  mov         ecx,dword ptr [ebp-10h] 
00000062  call        75D95F98 

In debug mode there&#039;s more code, but apart from the two constants in the first assembler line, there&#039;s no difference. To me it looks like identical pieces of code.

What am I doing wrong?</description>
		<content:encoded><![CDATA[<p>Are you sure there is a difference except your runtime environment in that last test there?</p>
<p>Here&#8217;s the two comparisons, disassembled in release-mode:</p>
<p>                if (TestValue == string.Empty)<br />
00000036  mov         edx,dword ptr ds:[022F102Ch]<br />
0000003c  mov         ecx,dword ptr [ebp-10h]<br />
0000003f  call        75D95F98 </p>
<p>                if (TestValue == &#8220;&#8221;)<br />
00000059  mov         edx,dword ptr ds:[022F202Ch]<br />
0000005f  mov         ecx,dword ptr [ebp-10h]<br />
00000062  call        75D95F98 </p>
<p>In debug mode there&#8217;s more code, but apart from the two constants in the first assembler line, there&#8217;s no difference. To me it looks like identical pieces of code.</p>
<p>What am I doing wrong?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
