C# number format

  • Thread starter Thread starter Inayat72
  • Start date Start date
I

Inayat72

Guest
hi

I have this code and I want to get number format different then what i'm getting. is this possible.

string d = "291465.679407";

double num;
decimal newnum;

NumberFormatInfo nfi = new NumberFormatInfo();
nfi.NumberDecimalSeparator = ".";
nfi.NumberDecimalDigits = 11;

double.TryParse(d, out num);
decimal.TryParse(d, out newnum);

Console.WriteLine(num.ToString("N", nfi));
Console.WriteLine(newnum.ToString("N", nfi));

Result is :

291,465.67940700000
291,465.67940700000

I want result as

291,465.67940699996
291,465.67940699996

Thanks

Continue reading...
 
Back
Top