title: Is there a built-in C# method to go from an empty string to null value?
body: <p>There are many times in which I have an input text, and, if it's empty (if the user didn't type any text, for example), I want to send a null value to the DB query.</p>
  <p>I do <strong>not</strong> want to send <code>String.Empty.</code> (or <code>&quot;&quot;</code>).</p>
  <p>Thus I find myself doing this a lot:</p>
  <pre><code>var mySqlValue =  string.IsNullOrEmpty( tbCustomerId.Text)?null:tbCustomerId.Text;
  </code></pre>
  <p>This seems ugly to me. .NET gives a lot of other solutions for the opposite scenarios:</p>
  <pre><code>string.IsNullOrEmpty
  string.IsNullOrWhiteSpace
  myProblemVal ?? myDefultVal
  </code></pre>
  <p>Is there anything built-in to C# that lets me do this a shorter way, like the opposite direction?</p>
  <p><strong>I know this can be solved by writing my own extension methods and I know how to do that; that's not a solution I'm interested in.</strong></p>
  <p>I'm looking for some code like &quot;<code>if empty -&gt; null</code>&quot;.</p>