title: Replace string value with '0' when string is empty
body: <p>I'm taking a value from a textbox and converting it to decimal. But, the textbox value could be empty. So, how could I handle empty strings from the textbox?</p>
  
  <p>Unfortunately I have around 50 textboxes to deal with, so answers like 'check for null with IF condition' won't help me. My code will look ugly if I use all those IF conditions.</p>
  
  <p>I have this</p>
  
  <pre><code>Convert.ToDecimal(txtSample.Text)
  </code></pre>
  
  <p>To handle nulls, I did this</p>
  
  <pre><code>Convert.ToDecimal(txtSample.Text = string.IsNullOrEmpty(txtSample.Text) ? "0" : txtSample.Text)
  </code></pre>
  
  <p>But, the above code is displaying '0' in the textbox. User does not want to see '0'. Another solution is to take text box value into a variable and convert the variable like below.</p>
  
  <pre><code>string variable = txtSample.Text;
  Convert.ToDecimal(variable = string.IsNullOrEmpty(variable) ? "0" : variable)
  </code></pre>
  
  <p>But again, I do not want to define around 50 variables. I am looking for some piece of code that handles null values during conversion without adding the extra line of code.</p>