> class Program > { > static string sa = "a"; > static string sb = "b"; > static string sc = "c"; > static string sd = "d"; > static string se = "e"; > static string sf = "f"; > static string sg = "g"; > static string s = sa + sb + sc + sd + se + sf + sg; > > > > > static void Main(string[] args) > { > > > string sa = "a"; > string sb = "b"; > string sc = "c"; > string sd = "d"; > string se = "e"; > string sf = "f"; > string sg = "g"; > string s = sa + sb + sc + sd + se + sf + sg; > > > > string x = sa + sb; > string pp = sa + sb + sc + sd; > } > } >>
>.method private hidebysig specialname rtspecialname static > void .cctor() cil managed >{ > // Code size 145 (0x91) > .maxstack 3 > .locals init ([0] string[] CS$0$0000) > IL_0000: ldstr "a" > IL_0005: stsfld string CoreTest.Program::sa > IL_000a: ldstr "b" > IL_000f: stsfld string CoreTest.Program::sb > IL_0014: ldstr "c" > IL_0019: stsfld string CoreTest.Program::sc > IL_001e: ldstr "d" > IL_0023: stsfld string CoreTest.Program::sd > IL_0028: ldstr "e" > IL_002d: stsfld string CoreTest.Program::se > IL_0032: ldstr "f" > IL_0037: stsfld string CoreTest.Program::sf > IL_003c: ldstr "g" > IL_0041: stsfld string CoreTest.Program::sg > IL_0046: ldc.i4.7 > IL_0047: newarr [mscorlib]System.String > IL_004c: stloc.0 > IL_004d: ldloc.0 > IL_004e: ldc.i4.0 > IL_004f: ldsfld string CoreTest.Program::sa > IL_0054: stelem.ref > IL_0055: ldloc.0 > IL_0056: ldc.i4.1 > IL_0057: ldsfld string CoreTest.Program::sb > IL_005c: stelem.ref > IL_005d: ldloc.0 > IL_005e: ldc.i4.2 > IL_005f: ldsfld string CoreTest.Program::sc > IL_0064: stelem.ref > IL_0065: ldloc.0 > IL_0066: ldc.i4.3 > IL_0067: ldsfld string CoreTest.Program::sd > IL_006c: stelem.ref > IL_006d: ldloc.0 > IL_006e: ldc.i4.4 > IL_006f: ldsfld string CoreTest.Program::se > IL_0074: stelem.ref > IL_0075: ldloc.0 > IL_0076: ldc.i4.5 > IL_0077: ldsfld string CoreTest.Program::sf > IL_007c: stelem.ref > IL_007d: ldloc.0 > IL_007e: ldc.i4.6 > IL_007f: ldsfld string CoreTest.Program::sg > IL_0084: stelem.ref > IL_0085: ldloc.0 > IL_0086: call string [mscorlib]System.String::Concat(string[]) > IL_008b: stsfld string CoreTest.Program::s > IL_0090: ret >} // end of method Program::.cctor >>
>.method private hidebysig static void Main(string[] args) cil managed
>{
> .entrypoint
> // Code size 124 (0x7c)
> .maxstack 4
> .locals init ([0] string sa,
> [1] string sb,
> [2] string sc,
> [3] string sd,
> [4] string se,
> [5] string sf,
> [6] string sg,
> [7] string s,
> [8] string x,
> [9] string pp,
> [10] string[] CS$0$0000)
> IL_0000: nop
> IL_0001: ldstr "a"
> IL_0006: stloc.0
> IL_0007: ldstr "b"
> IL_000c: stloc.1
> IL_000d: ldstr "c"
> IL_0012: stloc.2
> IL_0013: ldstr "d"
> IL_0018: stloc.3
> IL_0019: ldstr "e"
> IL_001e: stloc.s se
> IL_0020: ldstr "f"
> IL_0025: stloc.s sf
> IL_0027: ldstr "g"
> IL_002c: stloc.s sg
> IL_002e: ldc.i4.7
> IL_002f: newarr [mscorlib]System.String
> IL_0034: stloc.s CS$0$0000
> IL_0036: ldloc.s CS$0$0000
> IL_0038: ldc.i4.0
> IL_0039: ldloc.0
> IL_003a: stelem.ref
> IL_003b: ldloc.s CS$0$0000
> IL_003d: ldc.i4.1
> IL_003e: ldloc.1
> IL_003f: stelem.ref
> IL_0040: ldloc.s CS$0$0000
> IL_0042: ldc.i4.2
> IL_0043: ldloc.2
> IL_0044: stelem.ref
> IL_0045: ldloc.s CS$0$0000
> IL_0047: ldc.i4.3
> IL_0048: ldloc.3
> IL_0049: stelem.ref
> IL_004a: ldloc.s CS$0$0000
> IL_004c: ldc.i4.4
> IL_004d: ldloc.s se
> IL_004f: stelem.ref
> IL_0050: ldloc.s CS$0$0000
> IL_0052: ldc.i4.5
> IL_0053: ldloc.s sf
> IL_0055: stelem.ref
> IL_0056: ldloc.s CS$0$0000
> IL_0058: ldc.i4.6
> IL_0059: ldloc.s sg
> IL_005b: stelem.ref
> IL_005c: ldloc.s CS$0$0000
> IL_005e: call string [mscorlib]System.String::Concat(string[])
> IL_0063: stloc.s s
> IL_0065: ldloc.0
> IL_0066: ldloc.1
> IL_0067: call string [mscorlib]System.String::Concat(string,
> string)
> IL_006c: stloc.s x
> IL_006e: ldloc.0
> IL_006f: ldloc.1
> IL_0070: ldloc.2
> IL_0071: ldloc.3
> IL_0072: call string [mscorlib]System.String::Concat(string,
> string,
> string,
> string)
> IL_0077: stloc.s pp
> IL_0079: br.s IL_007b
> IL_007b: ret
>} // end of method Program::Main
Thx - very interesting to see that they varied the algorithm depending on the context
Nice to know I was right (although I admit that after considering your initial post I thought I was wrong ) :-}