missing one thing
string interestRate = String.Format("{0:0.0000}"
Main Topics
Browse All TopicsI am getting a decimal field from the database say 45.693043. I want to convert it to String and then format it to 4 decimal places . I was originally doing like this
string interestRate = ds.Tables[0].Rows[i]["IntR
string intRate = String.Format("{0:0.0000}"
I have tried String.Format("{0:F2}", interestRate ); and N2 ...did not work ...keeps me the original string...
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 don't have a table with an IntRate, or the time to construct it elaborately.
You can work with me on this, or you can wait for someone to get a fully working, QA tested solution for you if it's not pressing. If there was an error, you could tell me.
String.Format("{0:0.0000}"
If it cannot be explicitly cast to double, it could be because it's SQLDouble, not Double. Regardless of what it is (string/double/decimal), just retrieve it as string, and casting back to double.
Business Accounts
Answer for Membership
by: imitchiePosted on 2007-12-19 at 14:01:47ID: 20503378
string interestRate = Math.Round(ds.Tables[0].Ro ws[i]["Int Rate"],4). ToString() ;