title: How to stop C# from replacing const variable with their values?
body: <p>We have a project that's compiled into a DLL called consts.dll that contains something like:</p>
  
  <pre><code>public static class Consts
  {
      public const string a = "a";
      public const string b = "b";
      public const string c = "c";
  }
  </code></pre>
  
  <p>We have multiple projects of this sort, each compiled into a DLL of the same name (consts.dll) and we replace them according to need.
  We have another class that uses these consts:</p>
  
  <pre><code>public class ConstsUser 
  {
      string f() { return Consts.a; }
  }
  </code></pre>
  
  <p>Unfortunately, <code>Consts.a</code> is optimized to "a" , so even if we replace Consts.dll implementation, we still get "a" instead of the correct value and we need to recompile <code>ConstsUser</code>. Is there anyway to stop the optimizer from replacing const variables with their values?</p>