Вопрос

When i read from the XML file, i read it like this and it works,

decimal checkkkk = Config.Location.test.Longitude;
textBox3.Text = checkkkk.ToString(CultureInfo.InvariantCulture);

I want to write it back to the same XML file, I'm getting a error at this point..!

decimal value;
Configs.Location.test.Longitude = 
decimal.TryParse(textBox3.Text, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out value);

What is the mistake?

Это было полезно?

Решение

The method Decimal.TryParse returns the boolean data-type and not decimal.

Decimal.TryParse, Converts the string representation of a number to its Decimal equivalent using the specified style and culture-specific format. A return value indicates whether the conversion succeeded or failed.

Try to do it this way instead:

decimal value;
if (decimal.TryParse(textBox3.Text, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out value)) 
{
     rseConfigs.RseLocation.GpsCoordinates.Longitude = value;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top