Hallo miteinander,
[…]
Hi!
Ich hab’s mal explizit in verschiedenen Konstellationen
durchprobiert (WinXP deutsch, .NET 1.1)
string s1 = „3.14“;
string s2 = „3,14“;
float f1 = float.Parse(s1);
float f2 = float.Parse(s2);
float f3 = float.Parse(s1,
System.Globalization.CultureInfo.CurrentUICulture);
float f4 = float.Parse(s2,
System.Globalization.CultureInfo.CurrentUICulture);
float f5 = float.Parse(s1,
System.Globalization.CultureInfo.CreateSpecificCulture(„de-de“));
float f6 = float.Parse(s2,
System.Globalization.CultureInfo.CreateSpecificCulture(„de-de“));
float f7 = float.Parse(s1,
System.Globalization.CultureInfo.CreateSpecificCulture(„en-us“));
float f8 = float.Parse(s2,
System.Globalization.CultureInfo.CreateSpecificCulture(„en-us“));
Bei diesem Code ist es überall so, dass s1 (mit ‚.‘) in 314.0
gewandelt wird und s2 (mit ‚,‘) in 3.14.
Einzige Ausnahme ist die letzte Konvertierung, wo explizit
angegeben wurde, dass ich eine englische Culture verwenden
möchte, dort ist es (auch korrekterweise) umgekehrt: s1 ->
3.14, s2 -> 314.0
Geht das bei Dir nicht so?
Wie ich schrieb, war es bei mir nicht so. Nach mehrmaligem Restart funktioniert nun jedoch alles, ich habe aber keine Ahnung, warum. Dass es mit „en-us“ klappen sollte, war mir ja auch klar…
Wie auch immer, vielen Dank für die Hilfe!
Gruß
Alexander