Skip to content

Instantly share code, notes, and snippets.

@yohey03518
Created June 12, 2022 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohey03518/09d908b83639ebce22eaf3b61a77ac5b to your computer and use it in GitHub Desktop.
Save yohey03518/09d908b83639ebce22eaf3b61a77ac5b to your computer and use it in GitHub Desktop.
float num_float = 12345.0000f;
double num_double = 12345.0000;
decimal num_decimal = 12345.0000m;
Console.WriteLine("Current Culture (default) : " + Thread.CurrentThread.CurrentCulture.Name);
Console.WriteLine("num_float.ToString(\"F2\"): " + num_float.ToString("F2"));
Console.WriteLine("num_double.ToString(\"F2\"): " + num_double.ToString("F2"));
Console.WriteLine("num_decimal.ToString(\"F2\"): " + num_decimal.ToString("F2"));
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
Console.WriteLine("Current Culture: " + Thread.CurrentThread.CurrentCulture.Name);
Console.WriteLine("num_float.ToString(\"F2\"): " + num_float.ToString("F2"));
Console.WriteLine("num_double.ToString(\"F2\"): " + num_double.ToString("F2"));
Console.WriteLine("num_decimal.ToString(\"F2\"): " + num_decimal.ToString("F2"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment