Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6790
  • Last Modified:

C# Format Integer (Commas)

Visual Studio 2005 C#.Net 2.0

We have an application that computes an integer values, and then displays the value in a TextBox; very simple.
We would like to format the Integer value to include commas example:

54345         should be 54,345
123456789 should be 123,456,789
etc.

And we don't know how.
Thank you in advance.//
0
bmiller250
Asked:
bmiller250
  • 2
1 Solution
 
Ashish PatelCommented:
Try
String.Format({0:n});
0
 
bmiller250Author Commented:
Like thiss:

txtTotal.Text = String.Format({0:n}, "123465");
0
 
Ashish PatelCommented:
Try this
txtTotal.Text = "123465".Format({0:n});
0
 
Bob LearnedCommented:
1) You can't format string text as numeric

2) You would need a numeric type to perform that function

3) double n = 123456;
     this.txtTotal.Text = n.ToString("N0");

Bob
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now