Hi, I have a problem with the TypeConverter
class. It works fine with CultureInvariant
values but cannot convert specific cultures like English thousands separators. Below is a small test program that I cannot get to work.
Here's the problem :) - ConvertFromString
throws an exception with the following message "2,999.95 is not a valid value for Double." and with the inner exception "Input string was not in a correct format.".
using System;
using System.Globalization;
using System.ComponentModel;
class Program
{
static void Main()
{
try
{
var culture = new CultureInfo("en");
var typeConverter = TypeDescriptor.GetConverter(typeof(double));
double value = (double)typeConverter.ConvertFromString(
null,
culture,
"2,999.95");
Console.WriteLine("Value: " + value);
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
}
}
Edit: Link to the bug report on Connect