Is there a better way to convert to a specific type with reflection? Rather than doing what is essentially a large switch statement for every possible type, is there a better more generic way of converting to a specific type with reflection?  I've looked up TypeConverter but don't understand the documentation.

if (header.Property.PropertyType == typeof(Int32))
{
  header.Property.SetValue(instanceOfTrade, value.ToInt(), null);
}
else if (header.Property.PropertyType == typeof(decimal))
{
  header.Property.SetValue(instanceOfTrade, value.ToDecimal(), null);
}
else if (header.Property.PropertyType == typeof(DateTime))
{
  header.Property.SetValue(instanceOfTrade, value.TryToDateTime(), null);
}
else
{
  header.Property.SetValue(instanceOfTrade, value.ToString(), null);
}
You could use an extension method (if this is common), or a regular generic method with a &quot;IConvertible&quot; constraint on the desired value then call &quot;Convert.ChangeType&quot; in your SetValue call.
static class ObjectExtensions
{
    public static void SetPropertyValue&lt;T&gt;(this object obj, string propertyName, T propertyValue)
        where T : IConvertible
    {
        PropertyInfo pi = obj.GetType().GetProperty( propertyName );
        
        if( pi != null &amp;&amp; pi.CanWrite )
        {
            pi.SetValue
            (
                obj,
                Convert.ChangeType(propertyValue, pi.PropertyType),
                null
            );
        }
    }
}

class TestObject
{
    public string Property1 { get; set; }
    public int Property2 { get; set; }
}

void Main()
{
    TestObject o = new TestObject();
    
    // Propery1 == null, Property2 == 0
    o.SetPropertyValue( &quot;Property1&quot;, 1 );
    o.SetPropertyValue( &quot;Property2&quot;, &quot;123&quot; );
    // Propery1 == 1, Property2 == 123
}

Obviously no error handling and this is assuming you want it available on all types, so I just threw it in an &quot;ObjectExtensions&quot; class so it'll be visible on all types.
Just adjust the constraints to fit your exact needs, or just throw it in a regular class if you don't want to use extensions.