title: Exposing common values from a custom structure/type
body: <p>One of my projects has a value type/struct that represents a custom identifier string for a video format. In this case, it's going to contain a content type string, but that can vary.</p>
  
  <p>I've used a struct so it can be strongly type when it's passed around, and perform some sanity checks on the initial string value.</p>
  
  <pre><code>public struct VideoFormat {
      private string contentType;
  
      public VideoFormat(string contentType) {
          this.contentType = contentType;
      }
  
      public string ContentType {
          get { return this.contentType; }
      }
  
      public override string ToString() {
          return this.contentType;
      }
  
      // various static methods for implicit conversion to/from strings, and comparisons
  }
  </code></pre>
  
  <p>As there are a few very common formats, I've exposed these as static read only fields with default values.</p>
  
  <pre><code>public static readonly VideoFormat Unknown = new VideoFormat(string.Empty);
  public static readonly VideoFormat JPEG = new VideoFormat("image/jpeg");
  public static readonly VideoFormat H264 = new VideoFormat("video/h264");
  </code></pre>
  
  <p>Is it better to expose the common values as static read only fields or as get only properties? what if I want to change them later? I see both methods used throughout the .Net framework, e.g. <code>System.Drawing.Color</code> uses static readonly properties while <code>System.String</code> has a static read only field for <code>String.Empty</code>, and <code>System.Int32</code> has a const for <code>MinValue</code>.</p>
  
  <p>(Mostly copied from <a href="https://stackoverflow.com/q/15488575/588306">this question</a> but with a more specific and not directly related question.)</p>