I have a project which I have synchronised on two computers via GitHub. So the code is exactly the same but the double.TryParse()-Method behaves differently. For example:
string price = "5,50";
double parse_out;
if(double.TryParse(price.Replace(",", "."), out parse_out)
{
//output computer-1
//parse_out -> 5.50
//output computer-2
//parse_out -> 550
}
I am 100% sure, the code is the same. Visual Studio 2022 is up to date on both systems.
I've tried to just write something like "12.24" instead of price.Replace(). Same result.
It seems the only way the parse would behave like this is if you have different regional settings on the two computers. For example PT-BR uses "," as decimal while EN-US uses ".". The propper way to address the problem is making sure both computers have the same regional settings setup in windows or manually setup the regional setting in the beginning of the program
for .Net 7+
System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("pt-BR");//Here you use the culture string you wish, check https://stackoverflow.com/questions/15968625/culture-info-names for a list of them
System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new System.Globalization.CultureInfo("pt-BR");