title: How do I use Convert.ChangeType to cast to a specific class?
body: <p>Does anyone know how I can use Convert.ChangeType to cast from XML to a specific class?</p>
  
  <p>For example:</p>
  
  <p>My Property</p>
  
  <pre><code>public Point Loc
  {
      get { return GetValue&lt;Point2D&gt;("Loc"); }
      set { SetValue&lt;Point2D&gt;("Loc", value); }
  }
  </code></pre>
  
  <p>My XML:</p>
  
  <pre><code>&lt;Loc&gt;
   &lt;X&gt;1.0&lt;/X&gt;
   &lt;Y&gt;1.0&lt;/Y&gt;   
  &lt;/Loc&gt;
  </code></pre>
  
  <p>Call to convert:</p>
  
  <pre><code>prop.SetValue(targetObj, 
               Convert.ChangeType(xmlProperty.Value, prop.PropertyType));
  </code></pre>
  
  <p>I have looked at using IConvertible but none of the methods are being called.</p>
  
  <p>All of the examples I could find are using simple types. None show casting to an instance of a class.</p>
  
  <p>Thank you,</p>
  
  <p>Rick</p>