title: How can I assign a DBNull in a better way?
body: <p>I need to parse a value from a <code>DataRow</code> and assign it to another <code>DataRow</code>. If the input is valid, then I need to parse it to a <code>double</code>, or else add a <code>DBNull</code> value to the output. I'm using the following code:</p>
  
  <pre><code>public double? GetVolume(object data)
  {
      string colValue = data == null ? string.Empty : data.ToString();
      double volume;
  
      if (!Double.TryParse(colValue.ToString(), out volume))
      {
          return null;
      }
      return volume;
  }
  
  public void Assign(DataRow theRowInput,DataRow theRowOutput)
  {
      double? volume = GetVolume(theRowInput[0]);
  
      if(volumne.HasValue)
      theRowOutput[0] = volume.value;
      else
      theRowOutput[0] = DbNull.Value;
  
      return theRowOutput;
  }
  </code></pre>
  
  <p>Is there a better way to do it?</p>