title: Convert Null Value to String - C#.NET
body: <pre><code>    foreach (PropertyInfo PropertyItem in this.GetType().GetProperties())
      {
          PropertyItem.SetValue(this, objDataTable.Rows[0][PropertyItem.Name.ToString()], null);
      }
  </code></pre>
  
  <p>In one of the loops i get this exceptional error:</p>
  
  <p>Object of type 'System.DBNull' cannot be converted to type 'System.String'.</p>
  
  <p>The error occurs because one of the fields in the database has no value (null), so the string property could not handle it. How can i convert this null to string?</p>
  
  <p><a href="http://www.freevbcode.com/ShowCode.asp?ID=5280" rel="nofollow noreferrer">I got this solution</a></p>
  
  <p>If you know a shorter or better one, feel free to post it. I'm trying to avoid checking on every loop is current value is null or not.</p>