title: How to use the Convert.ChangeType(value, type) when the value is nullable
body: <p>I got an exception , when i am trying to convert the value to given type, but value holds null value.</p>
  
  <pre><code>//find out the type
  Type type = inputObject.GetType();
  
  //get the property information based on the type
  System.Reflection.PropertyInfo propertyInfo = type.GetProperty(propertyName);
  
  //find the property type
  Type propertyType = propertyInfo.PropertyType;
  
  //Convert.ChangeType does not handle conversion to nullable types
  //if the property type is nullable, we need to get the underlying type of the property
  var targetType = IsNullableType(propertyInfo.PropertyType) ? Nullable.GetUnderlyingType(propertyInfo.PropertyType) : propertyInfo.PropertyType;
  
  //Returns an System.Object with the specified System.Type and whose value is
  //equivalent to the specified object.
  propertyVal = Convert.ChangeType(propertyVal, targetType);
  </code></pre>
  
  <p>Here, propertyVal = holds null value, so its throws an exception.</p>
  
  <blockquote>
    <p>InvalidCastException: Null object cannot be converted to a value type.</p>
  </blockquote>
  
  <p>If there any way to fix this issue.</p>