title: String constants embedded twice in .Net?
body: <p>Say I have a simple (the simplest?) C# program:</p>
  
  <pre><code>class Program {
      static void Main() {
        System.Console.WriteLine("Hello, world");
      }
  }
  </code></pre>
  
  <p>If, I compile that code and look at the resultant .exe, I see the "Hello, world" string  in the exe image as expected.</p>
  
  <p>If I refactor the code to:</p>
  
  <pre><code>class Program {
      const string Greeting = "Hello, world";
      static void Main() {
        System.Console.WriteLine(Greeting);
      }
  }
  </code></pre>
  
  <p>If I compile that code and look at the resultant .exe, I see the "Hello, world" string literal in the exe image twice. This was surprising to me. I was under the impression that string literals were shared, and that it would therefor only show up in the image one time. Can anyone explain this? Perhaps this second copy of the string is needed for reflection metadata?</p>