title: How can I fix this up to do generic conversion to Nullable<T>?
body: <p>I currently use this handy conversion extension method to do conversions between types:</p>
  
  <pre><code>    public static T To&lt;T&gt;(this IConvertible obj)
      {
          return (T)Convert.ChangeType(obj, typeof(T));
      }
  </code></pre>
  
  <p>However, it doesn't like converting valid values to Nullable, for example, this fails:</p>
  
  <pre><code>    "1".To&lt;int?&gt;();
  </code></pre>
  
  <p>Obviously, 1 is easily converted to an (int?), but it gets the error:</p>
  
  <pre><code>    Invalid cast from 'System.String' to 'System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.
  </code></pre>
  
  <p>This is an obviously simplified example, in reality I'm using it to do conversions from string types like so:</p>
  
  <pre><code>packageDb.Quantity = package.package.ElementDeep(Namespace + "PackageQuantity", Namespace + "ActualQuantity", Namespace + "Quantity").ValueOrNull().To&lt;int?&gt;();
  </code></pre>
  
  <p>If Convert.ChangeType doesn't like Nullable, anyone have any great ideas?</p>