Skip to content

ToString("n") returns different decimal places on net5.0 vs netcoreapp3.1 #44587

@schotime

Description

@schotime

Below you will find a simple example that illustrates the issue.
The below code prints 21.000 in net5.0
If I replace the TargetFramework with netcoreapp3.1 it returns 21.00
I'm running 16.8 VS community.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
    <!--<TargetFramework>netcoreapp3.1</TargetFramework>-->
  </PropertyGroup>

</Project>
using System;
using System.Globalization;

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            CultureInfo.CurrentCulture = new CultureInfo("en-US");
            Console.WriteLine(21.ToString("n"));
        }
    }
}

image

Let me know if you need any more info or I'm doing something wrong.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions