Replace a character

Hi guys,

my input is 1.123,99
my output should be 1,123.99

the “,” should be replaced by “.” and the “.” should be replaced by “,”

Please help me out

The string length can vary. But both the symbols will be present in the string

Hi @karan_kapoor1

Please try this,

input - your variable

replace . with @
, with .
and finally @ with , again

input.tostring.replace(".","@").replace(",",".").replace("@",",")

Thanks

1 Like

thanks mate

1 Like

 Double.Parse("1.123,99",System.Globalization.CultureInfo.CreateSpecificCulture("de-DE"))
 1123.99
 Double.Parse("1.123,99",System.Globalization.CultureInfo.CreateSpecificCulture("de-DE")).toString("F2")
 "1123.99"
 Double.Parse("1.123,99",System.Globalization.CultureInfo.CreateSpecificCulture("de-DE")).toString("N2")
 "1,123.99"

feel free to use another culture e.g. your specific local one

1 Like