title: Does initialization of local variable with null impacts performance?
body: <p>Lets compare two pieces of code:</p>
  
  <pre><code>String str = null;
  //Possibly do something...
  str = "Test";
  Console.WriteLine(str);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>String str;
  //Possibly do something...
  str = "Test";
  Console.WriteLine(str);
  </code></pre>
  
  <p>I was always thinking that these pieces of code are equal. But after I have build these code (Release mode with optimization checked) and compared IL methods generated I have noticed that there are two more IL instructions in the first sample:</p>
  
  <p>1st sample code IL:</p>
  
  <p>.maxstack  1 <br/>
    .locals init ([0] string str)<br/>
    <strong>IL_0000:  ldnull<br/>
    IL_0001:  stloc.0<br/></strong>
    IL_0002:  ldstr      "Test"<br/>
    IL_0007:  stloc.0<br/>
    IL_0008:  ldloc.0<br/>
    IL_0009:  call       void [mscorlib]System.Console::WriteLine(string)<br/>
    IL_000e:  ret<br/></p>
  
  <p>2nd sample code IL:</p>
  
  <p>.maxstack  1<br/>
    .locals init ([0] string str)<br/>
    IL_0000:  ldstr      "Test"<br/>
    IL_0005:  stloc.0<br/>
    IL_0006:  ldloc.0<br/>
    IL_0007:  call       void [mscorlib]System.Console::WriteLine(string)<br/>
    IL_000c:  ret<br/></p>
  
  <p>Possibly this code is optimized by JIT compiller? 
  So does the initialization of local bethod variable with null impacts the performence (I understand that it is very simple operation but any case) and we should avoid it?
  Thanks beforehand.</p>