title: Converting C# to VB: New... With {Read-Only Property}
body: <p>In trying to convert the following C# code from a tutorial (by hand, since cross-compilers I have tried don't seem to be able to do this):</p>
  
  <pre><code>httpClient = new HttpClient(unrelated args)
  {
      DefaultRequestHeaders = 
      { 
          Accept = { MediaTypeWithQualityHeaderValue.Parse("text/json") } 
      }
  }
  </code></pre>
  
  <p>The closest I have been able to get it is:</p>
  
  <pre><code>Dim httpClient As New HttpClient(unrelated args) With
  {
      .DefaultRequestHeaders [=[New HttpRequestHeaders]] [With] 
      {
          .Accept = {MediaTypeWithQualityHeaderValue.Parse("text/json") 
      }
  }
  </code></pre>
  
  <p>(where I have tried various combinations of the values in brackets)</p>
  
  <p>No matter what I try, the best I can get is the error </p>
  
  <blockquote>
    <p>Property <code>DefaultRequestHeaders</code> is <code>ReadOnly</code>.</p>
  </blockquote>
  
  <p>I have confirmed that <code>.DefaultRequestHeaders</code> and <code>.Accept</code> are ReadOnly in both VB and C#. Apparently C# is able to write to ReadOnly properties at initialization? Is VB not able to do this as well, or is there some nuance of syntax I am missing to be able to do this? Failing being able to set this at initialization, some other way to set the actual value would presumably work; unfortunately, I don't see a constructor that exposes it, so I don't see any other way to accomplish this, though I would also welcome any suggestion along those lines.</p>