المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How to show only 2 decimal points when using a double



C# Programming
09-16-2009, 04:40 AM
Hi people

I have a TextBlock that displays a calculated cost. The cost is stored in a double, and then I set TextBlock.Text to the cost.ToString(). What I want to know is, how do I convert this double value so that it displays only 2 decimal points e.g 56.99. Because at the moment it displays something like the following: 56.9999999999.