Click here to Skip to main content
15,886,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to display number in thousands format,tried using {0:n},but not working.

ANy help wud be gud.

for ex 12345 as 12,345
Posted
Comments
V. 11-Apr-12 7:17am    
post your relevant piece of code?
Also please use full sentences (would, good, ...)

Use {0:#,0}
To specify number grouping say 14,33,234, the culture which uses such grouping say "hi-IN" has to be used as shown below
C#
CultureInfo cultureInfo = new CultureInfo("hi-IN");
int number = 45454569;
string formattedNumber = number.ToString("#,0",cultureInfo);
Console.WriteLine (formattedNumber);
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Apr-12 21:49pm    
Yes, this is how IFormatProvider (the interface implemented by CultureInfo) and format string work together. A 5.
--SA
VJ Reddy 11-Apr-12 22:25pm    
Thanks you, SA.
hi,
try this:
C#
int number = 100922982;
string whatYouWant = number.ToString("#,##0");
//you get 100,922,982

Cheers
 
Share this answer
 
v2
#,##0,

The trailing comma scales by 1000.
 
Share this answer
 
already asked in CP..go through the URL

add comma to numbers in gridvew[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900