top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Formating Number, thousands commaI(,) separator with decimal places in textbox wp8 using c#?

+1 vote
345 views

windows phone 8 application TextBox accept currency values display decimal,thousand comma seperator
eg: 120.00// 1,200.00 etc

posted Nov 4, 2014 by Saravanan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

Few different ways how you can format a decimal number (float, double, or decimal).

Setting the Maximum Allowed Decimal Places:

To format your numbers to a maximum of two decimal places use the format string {0:0.##} as shown in the below example:

string.Format("{0:0.##}", 256.583); // "256.58"
string.Format("{0:0.##}", 256.586); // "256.59"
string.Format("{0:0.##}", 256.58); // "256.58"
string.Format("{0:0.##}", 256.5); // "256.5"
string.Format("{0:0.##}", 256.0); // "256"

Setting a Fixed Amount of Decimal Places:

This is similar to the above example but instead of hashes (‘#’) in our format string we are going to use zeroes (‘0’) as shown below:

string.Format("{0:0.00}", 256.583); // "256.58"
string.Format("{0:0.00}", 256.586); // "256.59"
string.Format("{0:0.00}", 256.58); // "256.58"
string.Format("{0:0.00}", 256.5); // "256.50"
string.Format("{0:0.00}", 256.0); // "256.00"

The Thousand Separator:

To format your decimal number using the thousand separator, use the format string {0:0,0} as shown in the below example:

string.Format("{0:0,0.00}", 1234256.583); // "1,234,256.58"
string.Format("{0:0,0}", 1234256.583); // "1,234,257"

answer Nov 6, 2014 by Jdk
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...