title: Can I safely substitute a readonly property for a readonly public field?
body: <p>My team follows the general .NET convention that you should expose public properties on your types rather than exposing fields. However, I've come across a class which <em>mostly</em> exposes fields... but then contains this for its two 'identifying' pieces of data:</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>public readonly int WidgetId;
  public readonly string WidgetName;
  </code></pre>
  
  <p>I am really heavily tempted to refactor these into properties, i.e.</p>
  
  <pre class="lang-cs prettyprint-override"><code>public int WidgetId { get; }
  public string WidgetName { get; }
  </code></pre>
  
  <p>So they match the conventions of the rest of the class. I'm aware of the arguments for and against public fields versus properties. But, given that <em>readonly-auto-properties</em> in particular are a relatively new C# feature, I want to know:</p>
  
  <p>What are the semantic differences between <code>public readonly int Foo</code> and <code>public int Foo { get; }</code>, if any? Are they meaningfully different to the compiler?</p>