title: How to serialize static or const member variables using JSON.NET?
body: <p>I haven't been able to find the answer to this anywhere, but when I try to serialize a struct or class with static or const member variables, they don't serialize by default.  If I try to force serialization by setting <code>MemberSerialization.OptIn</code>, I get an error.</p>
  
  <p>ex.</p>
  
  <pre><code>[JsonObject(MemberSerialization.OptIn)]
  public class Test
  {    
      [JsonProperty]
      public int x = 1;
  
      [JsonProperty]
      public static int y = 2;
  }
  </code></pre>
  
  <p>If I try to serialize this class with:</p>
  
  <pre><code>Test t = new Test();
  string s = JsonConvert.SerializeObject( t );
  </code></pre>
  
  <p>I get the error <code>Error getting value from 'y' on 'Test'</code>.  The same happens if y is const.</p>
  
  <p>My theory is that static and const values are stored somewhere special in memory, and for some reason the Json serializer dies trying to access them.  That's entirely a hunch though, and I see nothing in the <a href="http://msdn.microsoft.com/en-us/library/vstudio/98f28cdx%28v=vs.110%29.aspx">C# Reference for Static</a> that's of any help.  I'm relatively new to C# - and this is really a curiosity question more than anything at this point.</p>