Click here to Skip to main content
15,884,013 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I wish to have a Commas for digits. Is it possible?

C#
decimal Val1=155000;
textBox1.Text = string.Format("{0:N2}", Val1);


The Above Codes O/P
155,000.00

But I wish to have 1,55,000.00 Is it possible?
Thanks
Posted

Solution:
C#
int number = 1000000000;
            string whatYouWant = number.ToString("#,##0");
 
Share this answer
 
Set the Culture and UICulture attributes of the @ Page directive
.aspx Page

C#
<![CDATA[<%@ Page UICulture="hi" Culture="hi-IN"  %>


C#.page

C#
decimal Val1 = 155000;
      TextBox textBox1 = new TextBox();
      textBox1.Text = string.Format("{0:C2}", Val1);


Updated:
C#
textBox1.Text = string.Format("{0:N2}", Val1);
 
Share this answer
 
v3
Comments
Paramu1973 17-Mar-15 8:51am    
No. I don't want to get $155,000.00.
But I wish to get 1,55,000.00
King Fisher 17-Mar-15 8:52am    
Updated
Paramu1973 17-Mar-15 9:17am    
{0:C2} displays the Currency Symbal first then the numbers..But Iam looking like the below
$ 155,000.00 Its Not Required
But I need 1,55,000.00
Thanks
King Fisher 17-Mar-15 9:18am    
See I have updated the Solution .use N2 instead of C2
Yes - see here: https://msdn.microsoft.com/en-us/library/syy068tk(v=vs.90).aspx[^]
You need to select CultureInfo("hi-IN") IIRC
 
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