Comma Instead Of Decimal Point

In countries such as Germany they use commas as decimal points (e.g. -0,136222).  So if your program is converting a string like this:


	String ^sTemp;
	Single Value;
	sTemp = "1.234";
	Value = Convert::ToSingle(sTemp);

What you will actually get is 1234 in Value – the decimal point is ignored.

Correctly Handling Conversions From Strings

	String ^sTemp;
	Single Value;
	sTemp = "1.234";
	Value = Single::Parse(sTemp, System::Globalization::CultureInfo::InvariantCulture);
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published.