Click here to Skip to main content
15,914,221 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How To Round Up To Two Decimal Places

i have label , i want to bind the value in this label, in code behind how can i round up the 2 decimal value
Posted

Hi,
C#
yourlabel.Text=yourvalue.ToString("{.00}");

Hope this helps.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 12-Dec-11 3:05am    
Good question, my 5. I bet OP does not really need rounding -- it is rarely needed. Formatting a number as a string -- this is all what usually needed.
--SA
AmitGajjar 12-Dec-11 3:49am    
Hi SA,

rounding is required when you are dealing with currency, because 5.559 should not be 5.55 it should be 5.56. so it may cause major problem depending upon calculation.

thanks
-Amit.
see
Number rounding in JavaScript
in C# use
C#
decimal a = 1.994444;

Math.Round(a, 2);

see more
Math.Round
 
Share this answer
 
v2
Comments
Tisha Ahuja 28-Aug-12 2:22am    
No it gives error 'ToString' takes '1' arguments
How to solve this error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900