title: Should I try to use const string instead of string wherever possible?
body: <p>Consider these three examples:</p>
  
  <p>Example A</p>
  
  <pre><code>string message = "Hello world!";
  throw new System.Exception(message);
  </code></pre>
  
  <p>Example B</p>
  
  <pre><code>const string message = "Hello world!";
  throw new System.Exception(message);
  </code></pre>
  
  <p>Example C</p>
  
  <pre><code>throw new System.Exception("Hello world!");
  </code></pre>
  
  <p>Is there any reason to use one over the others?  Specifically, shouldn't I try to use const string where possible (assuming the string is never modified), and therefore Example B is best?  What happens in Example C?</p>
  
  <p>I guess I'm asking if the IL emitted by the above are identical or different, and if there is any difference.  I recognize that the difference will be small and probably not anything to worry about; I guess that makes this an academic question.</p>
  
  <hr>
  
  <h2>Edit.  Here's the IL</h2>
  
  <pre><code>IL_0014: ldstr "This is a string"
  IL_0019: stloc.0
  IL_001a: ldloc.0
  IL_001b: newobj instance void [mscorlib]System.Exception::.ctor(string)
  IL_0020: throw
  
  
  IL_0033: nop
  IL_0034: ldstr "This is a const string"
  IL_0039: newobj instance void [mscorlib]System.Exception::.ctor(string)
  IL_003e: throw
  
  IL_0051: nop
  IL_0052: ldstr "This is an inline string."
  IL_0057: newobj instance void [mscorlib]System.Exception::.ctor(string)
  IL_005c: throw
  </code></pre>
  
  <p>Looks substantively identical to me.</p>