I am writing a C # program to convert model formats. The model format has numbers in the form of text, such as "-0.136222".
I can use System.Convert.ToSingle () to convert this number to a floating point number. But here in Germany, we use commas as decimal points (-0.136222), and System.Convert chooses this. Now I have a problem of not recognizing decimal points, since it expects commas.
In a nutshell; We have the following: "-0.136222" We get the following: -0136222.0f because it expects this: "-0.136222"
Can I tell the system to recognize commas as decimal points only for my program? Work around will not work, because it must be portable (to other countries).
Use Single.Parse () instead, for example:
Single.Parse("-0.136222", CultureInfo.InvariantCulture);
InvariantCulture is a way to tell a parser to a string, ignoring individual decimal separators and grouping separators.
.. Framework.Net, , , . , , float , , , , .
float
, Culture .Net CultureInfo.InvariantCulture ( Pawel ) CultureInfo, , . :)
Culture
CultureInfo.InvariantCulture
CultureInfo
. , () , , , float , , , .
Source: https://habr.com/ru/post/1545768/More articles:Avoiding vertical text / characters - htmlWhere is the annotation in sleep mode with the date as a condition - javaПредложение, показывающее половину в конце div, переполнение: скрытое сокращает предложение - htmlКак заставить InvariantCulture распознавать запятую как десятичный разделитель? - floating-pointR - Delete a tag without deleting a label - rВозврат лямбда-функции с захватом перемещения - c++QML - Passing an associative Javascript array in C ++ - c ++Are you running test run tests at the same time? - unit-testinghttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1545772/spring-repository-annotation-does-not-work-but-service-annotation-does&usg=ALkJrhj_5huIA7iMaXOiQ8kLdkPEv7JsvAHow to RelativeLayout Align Center android - androidAll Articles