I have a string "-6.379885574693132E-10"
that I can't convert to decimal..is it to big? Is it possible to work around this?
Error:
Input string was not correct format
public class Program {
private static void Main(string[] args) {
Foo foo = new Foo();
var str = "-6.379885574693132E-10";
foo.SetPropertyValue("myVal", str);
}
}
public class Foo {
public decimal myVal { get; set; }
public void SetPropertyValue(string propertyName, object value) {
var propertyInfo = GetType().GetProperty(propertyName);
propertyInfo.SetValue(this,
Convert.ChangeType(value, propertyInfo.PropertyType, CultureInfo.InvariantCulture), null);
}
}