should be string str_price=price.ToString()
Main Topics
Browse All TopicsI have two statements
string str_price=String.Format("{
str_price=String.Format("{
I get the error FormatException
Please let me know how to apply the two formatting styles.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
i have a price double and I want this variable to be outputed in a text email with two zeros after the point, that is what {0:f} does, then I want to allign this variable to the left in a column and that is what {1,10 } does.
I have the following text
Part#: Description Price (USD)
--------------------------
60-15B-120T Roll 15W / 1.5 x 60/11.25amps $903.00
TH115-F-120GA Prog.tstat w/GFI and Sensor 120V $149.00
--------------------------
Subtotal: $1052.00
Tax (IL): $65.75
Shipping charges: $15.00
--------------------------
Total $1132.75
I want this to be like: (notice the money column)
Part#: Description Price (USD)
--------------------------
60-15B-120T Roll 15W / 1.5 x 60/11.25amps $903.00
TH115-F-120GA Prog.tstat w/GFI and Sensor 120V $149.00
--------------------------
Subtotal: $1052.00
Tax (IL): $65.75
Shipping charges: $15.00
--------------------------
Total $1132.75
I want the money column to be aligned to the left and have the two zeros displayed after the point.
hi,
string str_price=String.Format("{
if im not mistaken this formatting is using the {n,w} format where n is parameter index and w is the width..
it could be {0,10} instead of {1,10} since you only have one parameter "price"
can you please try this instead
--------------------------
string str_price=String.Format("{
--------------------------
hope it helps
also, most of the time, i use to achieve the same results using a single formatting (currency, two decimal places and align right)
to align left just use a negative number instead like {0,-10:C2}
and you might want to use the same formatting
--------------------------
String.Format("{0,10:C2}",
--------------------------
hope it works and helps
Business Accounts
Answer for Membership
by: bruintjePosted on 2005-11-22 at 16:06:21ID: 15346806
Hello warmlyyours,
0:f}", str_price);
log.aspx/2 004071401
think the problem is in the first part assuming price is a double or at least a non string convert that to string first
string str_price=price.toString;
str_price=String.Format("{
for more on the string.format you could look at
source: http://idunno.org/displayB
hope this helps a bit
bruintje