Link to home
Start Free TrialLog in
Avatar of Jesper Christensen
Jesper Christensen

asked on

formatnumber

1799,
How can I show this number as 1.799

In classic asp i just write formatnumber()

How in c# ?
Avatar of rockiroads
rockiroads
Flag of United States of America image

have u tried tostring("N3") on your variable? you may need to divide by 1000
ASKER CERTIFIED SOLUTION
Avatar of w00te
w00te
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or is this supposed to be the 1000th character?
http://msdn.microsoft.com/en-us/library/0c899ak8(v=VS.100).aspx
double value;

value = 123;
Console.WriteLine(value.ToString("00000"));
// Displays 00123

value = 1.2;
Console.WriteLine(value.ToString("0.00", CultureInfo.InvariantCulture));
// Displays 1.20
Console.WriteLine(value.ToString("00.00", CultureInfo.InvariantCulture));
// Displays 01.20
Console.WriteLine(value.ToString("00.00", 
                  CultureInfo.CreateSpecificCulture("da-DK")));
// Displays 01,20

value = .56;
Console.WriteLine(value.ToString("0.0", CultureInfo.InvariantCulture));
// Displays 0.6

value = 1234567890;
Console.WriteLine(value.ToString("#,#", CultureInfo.InvariantCulture));	
// Displays 1,234,567,890      
Console.WriteLine(value.ToString("#,#", 
                  CultureInfo.CreateSpecificCulture("el-GR")));	
// Displays 1.234.567.890      

Open in new window

Avatar of Jesper Christensen
Jesper Christensen

ASKER

Thanks for the answers. I will try if it works and get back to you
This is correct syntax:
{0:0,00}