0

Im migrating my application from Dot Net Framework to Containerised Dot Net Core 6. Running this code to print a Negative Currency Value.

CultureInfo.CurrentCulture = new CultureInfo("en-US");
CultureInfo.CurrentUICulture = new CultureInfo("en-us");
Console.WriteLine(string.Format("{0:c}", -495));

In Dot-Net Framework and Dot-net core In Windows the Behaviour is ($495) and in Dot-Net Core container it is displayed as -$495. I cannot hard code in my application but I was hoping to making changes in the locale of the docker container. Is there any ways to achieve this.

John Varkey
  • 70
  • 1
  • 1
  • 5

1 Answers1

1

You can try set the current thread with the desired culture

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUiCulture = new CultureInfo("en-US");

Or directly the string format method:

Format string by CultureInfo