Decimal value formatting . NET Framework

Asked

Viewed 24 times

0

Considering the code below, how can I change the return of .7777 for 0.7777?

using System;
using System.Globalization;

namespace Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal x = 0.7777M;
            var y = x.ToString("#.#######", CultureInfo.CreateSpecificCulture("en-US"));
            Console.WriteLine(y);
            Console.ReadKey();
        }
    }
}
  • Why? You’re doing this?

1 answer

1


Would that be ?

decimal x = 0.7777M;
var y = x.ToString("0.0000", CultureInfo.CreateSpecificCulture("en-US"));
Console.WriteLine(y);  

Browser other questions tagged

You are not signed in. Login or sign up in order to post.