Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
GeneralRe: Weird C# String Behavior Pin
malharone6-Feb-06 5:29
malharone6-Feb-06 5:29 
GeneralRe: Weird C# String Behavior Pin
Judah Gabriel Himango6-Feb-06 7:15
sponsorJudah Gabriel Himango6-Feb-06 7:15 
AnswerRe: Weird C# String Behavior Pin
leppie6-Feb-06 5:16
leppie6-Feb-06 5:16 
GeneralRe: Weird C# String Behavior Pin
malharone6-Feb-06 5:36
malharone6-Feb-06 5:36 
AnswerRe: Weird C# String Behavior Pin
Nish Nishant6-Feb-06 6:06
sitebuilderNish Nishant6-Feb-06 6:06 
GeneralRe: Weird C# String Behavior Pin
malharone6-Feb-06 6:20
malharone6-Feb-06 6:20 
GeneralRe: Weird C# String Behavior Pin
Daniel Grunwald6-Feb-06 6:55
Daniel Grunwald6-Feb-06 6:55 
GeneralNoooo! Pin
leppie6-Feb-06 7:49
leppie6-Feb-06 7:49 
Its just a compiler optimization, called constant folding. From the IL you can clearly see the same string reference has been assigned from the string table.
<FONT color=DarkBlue>.method</FONT> <FONT color=DarkGreen>/*06000001*/</FONT> <FONT color=Blue>private hidebysig static</FONT>
        <FONT color=Blue>void</FONT>  Main(<FONT color=Blue>string</FONT><FONT color=DarkBlue>[]</FONT> args) <FONT color=Blue>cil managed</FONT>
<FONT color=DarkGreen>// SIG: 00 01 01 1D 0E</FONT>
{
  <FONT color=DarkBlue>.entrypoint</FONT>
  <FONT color=DarkGreen>// Method begins at RVA 0x2050</FONT>
  <FONT color=DarkGreen>// Code size       31 (0x1f)</FONT>
  <FONT color=DarkBlue>.maxstack</FONT>  <FONT color=Red>2</FONT>
  <FONT color=DarkBlue>.locals</FONT> <FONT color=DarkGreen>/*11000001*/</FONT> <FONT color=Blue>init</FONT> (<FONT color=Blue>string</FONT> V_0<FONT color=DarkBlue>,</FONT>
           <FONT color=Blue>string</FONT> V_1)
  <FONT color=DimGray>IL_0000:</FONT>  <FONT color=DarkGreen>/* 72   | (70)000001       */</FONT> <FONT color=DeepPink>ldstr</FONT>      <FONT color=Maroon>"ABC"</FONT> <FONT color=DarkGreen>/* 70000001 */</FONT>
  <FONT color=DimGray>IL_0005:</FONT>  <FONT color=DarkGreen>/* 0A   |                  */</FONT> <FONT color=DeepPink>stloc.0</FONT>
  <FONT color=DimGray>IL_0006:</FONT>  <FONT color=DarkGreen>/* 72   | (70)000001       */</FONT> <FONT color=DeepPink>ldstr</FONT>      <FONT color=Maroon>"ABC"</FONT> <FONT color=DarkGreen>/* 70000001 */</FONT>
  <FONT color=DimGray>IL_000b:</FONT>  <FONT color=DarkGreen>/* 0B   |                  */</FONT> <FONT color=DeepPink>stloc.1</FONT>
  <FONT color=DimGray>IL_000c:</FONT>  <FONT color=DarkGreen>/* 06   |                  */</FONT> <FONT color=DeepPink>ldloc.0</FONT>
  <FONT color=DimGray>IL_000d:</FONT>  <FONT color=DarkGreen>/* 07   |                  */</FONT> <FONT color=DeepPink>ldloc.1</FONT>
  <FONT color=DimGray>IL_000e:</FONT>  <FONT color=DarkGreen>/* 28   | (0A)000002       */</FONT> <FONT color=DeepPink>call</FONT>       <FONT color=Blue>bool</FONT> <FONT color=DarkBlue>[</FONT>mscorlib<FONT color=DarkGreen>/* 23000001 */</FONT><FONT color=DarkBlue>]</FONT>System.Object<FONT color=DarkGreen>/* 01000001 */</FONT>::ReferenceEquals(<FONT color=Blue>object</FONT><FONT color=DarkBlue>,</FONT>
                                                                                                                               <FONT color=Blue>object</FONT>) <FONT color=DarkGreen>/* 0A000002 */</FONT>
  <FONT color=DimGray>IL_0013:</FONT>  <FONT color=DarkGreen>/* 28   | (0A)000003       */</FONT> <FONT color=DeepPink>call</FONT>       <FONT color=Blue>void</FONT> <FONT color=DarkBlue>[</FONT>mscorlib<FONT color=DarkGreen>/* 23000001 */</FONT><FONT color=DarkBlue>]</FONT>System.Console<FONT color=DarkGreen>/* 01000003 */</FONT>::WriteLine(<FONT color=Blue>bool</FONT>) <FONT color=DarkGreen>/* 0A000003 */</FONT>
  <FONT color=DimGray>IL_0018:</FONT>  <FONT color=DarkGreen>/* 28   | (0A)000004       */</FONT> <FONT color=DeepPink>call</FONT>       <FONT color=Blue>string</FONT> <FONT color=DarkBlue>[</FONT>mscorlib<FONT color=DarkGreen>/* 23000001 */</FONT><FONT color=DarkBlue>]</FONT>System.Console<FONT color=DarkGreen>/* 01000003 */</FONT>::ReadLine() <FONT color=DarkGreen>/* 0A000004 */</FONT>
  <FONT color=DimGray>IL_001d:</FONT>  <FONT color=DarkGreen>/* 26   |                  */</FONT> <FONT color=DeepPink>pop</FONT>
  <FONT color=DimGray>IL_001e:</FONT>  <FONT color=DarkGreen>/* 2A   |                  */</FONT> <FONT color=DeepPink>ret</FONT>
} <FONT color=DarkGreen>// end of method Class1::Main</FONT>


xacc.ide-0.1.2.6
New syntax highlight screenshots of xacc.ide

QuestionWierdness trying to use a class library in a service Pin
ByStorm Software6-Feb-06 4:22
ByStorm Software6-Feb-06 4:22 
AnswerRe: Wierdness trying to use a class library in a service Pin
Joe Woodbury6-Feb-06 4:54
professionalJoe Woodbury6-Feb-06 4:54 
AnswerRe: Wierdness trying to use a class library in a service Pin
leppie6-Feb-06 7:57
leppie6-Feb-06 7:57 
GeneralRe: Wierdness trying to use a class library in a service Pin
ByStorm Software6-Feb-06 9:48
ByStorm Software6-Feb-06 9:48 
QuestionXsltArgumentList doesn't accept long parameter values Pin
mikko laanti6-Feb-06 4:21
mikko laanti6-Feb-06 4:21 
AnswerRe: XsltArgumentList doesn't accept long parameter values Pin
leppie6-Feb-06 5:21
leppie6-Feb-06 5:21 
QuestionAdd to favourites Pin
Brendan Vogt6-Feb-06 3:51
Brendan Vogt6-Feb-06 3:51 
Questionstatus bar Pin
Kola Sokol6-Feb-06 3:41
Kola Sokol6-Feb-06 3:41 
AnswerRe: status bar Pin
Ravi Bhavnani6-Feb-06 4:04
professionalRavi Bhavnani6-Feb-06 4:04 
GeneralRe: status bar Pin
Kola Sokol6-Feb-06 5:06
Kola Sokol6-Feb-06 5:06 
Questionmemcopy in C# ? Pin
smoitry6-Feb-06 3:28
smoitry6-Feb-06 3:28 
AnswerRe: memcopy in C# ? Pin
Judah Gabriel Himango6-Feb-06 4:58
sponsorJudah Gabriel Himango6-Feb-06 4:58 
QuestionHelp with multiview control needed!! Pin
BenPage6-Feb-06 2:07
BenPage6-Feb-06 2:07 
Questionbit + sq Pin
ita_cas6-Feb-06 1:48
ita_cas6-Feb-06 1:48 
AnswerRe: bit + sq Pin
albCode6-Feb-06 2:01
albCode6-Feb-06 2:01 
Questioncombo box, datagrid problem Pin
steve1_rm20006-Feb-06 1:31
steve1_rm20006-Feb-06 1:31 
QuestionHow to create RadioButtonColumn for DataGridView Pin
USrinivas6-Feb-06 1:17
USrinivas6-Feb-06 1:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.