This code –
Convert.ToDecimal("28.9100000000000000").ToString("c")
will convert a string containing a decimal value to a nicely formatted currency value. Is there anyway to do this without first converting the string value to a decimal?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In order to preserve culture specific currency attributes (currency symbol, separators and precision), your current approach looks like the best one.
If you know the precision and don’t care about cultures, you can do some simple string manipulation: