title: C# Nullable: How to build a FormUrlEncodedContent from Dictionary<string,string>
body: <p>I have a <code>Dictionary&lt;string,string&gt;</code> of parameters and want to create a <code>FormUrlEncodedContent</code>. See the following sample code:</p>
  <pre class="lang-cs prettyprint-override"><code>var message = new Dictionary&lt;string,string&gt; {{&quot;example&quot;, &quot;example&quot;}};
  var content = new FormUrlEncodedContent(message);
  </code></pre>
  <p>This code works fine with nullable disabled, but enabling it leads to a warning (and since we have WarningsAsErrors enabled, the build fails).</p>
  <pre><code>Argument of type 'System.Collections.Generic.Dictionary&lt;string,string&gt;' cannot
  be used for parameter 'nameValueCollection' of type 
  'System.Collections.Generic.IEnumerable&lt;System.Collections.Generic.KeyValuePair&lt;string?,string?&gt;&gt;'
  in 'System.Net.Http.FormUrlEncodedContent.FormUrlEncodedContent'
  due to differences in the nullability of reference types.
  </code></pre>
  <p>I have worked around this by doing <code>message.Select(kvp =&gt; new KeyValuePair&lt;string?, string?&gt;(kvp.Key, kvp.Value))</code>, but this is very verbose, gross, and probably slower.</p>
  <p>Any suggestions? Am I missing an obvious way to cast this, or is the <code>FormUrlEncodedContent</code> class wrong for accepting a <code>KeyValuePair&lt;string?, string?&gt;</code>?</p>