Microsoft
Software
Hardware
Network
Question : String.Format not working when using Label Text
I have the following code which I am using to display calculated averages into various labels. When I use the String.Format to control the display of decimal places it has no effect and displays numbers with several numbers to the right of the decimal point.
Example. It will display 266.167689999999 where I want it to only display 266.17
Here is the code to populate the Labels:
//***** divide Total by count to get average ********
decimal lodgingAdvAvg = lodgingAdvTotal / lodgingAdvCount;
//****** Display Results on Label Text and format to 2 decimal points ***********
lblLodgingAdv.Text = String.Format("{0:d}", lodgingAdvAvg.ToString());
Answer : String.Format not working when using Label Text
try this in between:
Math.Round(lodgingAdvAvg,2
);
Random Solutions
Jmagick how to resample when changing DPI
Using maps with GWT
RAID 10 array keeps failing on HP P410i
Dell PowerEdge server life cycle -- predictions from real life experience
redirecting domain.com to
www.domain.com
in IIS7?
High Insert/Update time because of Trigger
Vmware Virtual Centre Service not starting
Sonic Wall Continuous Backup Problem
how to avoid echo in 1 on 1 video chat / conference-system with FMS 3,5
Cropping Photos Without Changing The Aspect Ratio in Fireworks 8