title: Why does C# limit the set of types that can be declared as const?
body: <p>Compiler error <a href="http://msdn.microsoft.com/en-us/library/ms228656(VS.80).aspx" rel="noreferrer">CS0283</a> indicates that only the basic POD types (as well as strings, enums, and null references) can be declared as <code>const</code>. Does anyone have a theory on the rationale for this limitation? For instance, it would be nice to be able to declare const values of other types, such as IntPtr.</p>
  
  <p>I believe that the concept of <code>const</code> is actually syntactic sugar in C#, and that it just replaces any uses of the name with the literal value. For instance, given the following declaration, any reference to Foo would be replaced with "foo" at compile time.</p>
  
  <pre><code>const string Foo = "foo";
  </code></pre>
  
  <p>This would rule out any mutable types, so maybe they chose this limitation rather than having to determine at compile time whether a given type is mutable?</p>