i have textbox1 in that i have this value 2784.56894455
i want to round off the above value to 2785.
please send the code.
Regards,
RAO
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 11, 2012, 3:20 AM EDT
double value = 2784.56894455;
value = Math.Round(value);
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 11, 2012, 4:02 AM EDT
Alternate way
string text = "2784.56894455";
decimal value;
if (decimal.TryParse(text, out value))
{
value = Math.Round(value);
MessageBox.Show(value.ToString());
}
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 11, 2012, 4:46 AM EDT
you can also do thing using casting in int.
double dou = 123.333;
int i = Convert.ToInt32(dou); --> return 123 and if dou = 123.55 then return 124
hope this will help.
Satyapriya NayakRank #47 · 31.5K reputationPosted Dec 5, 2012, 2:25 AM EST