Click here to Skip to main content
16,014,290 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I have a variable in the cs page with the type Float,
and this variable values are display in text box 99.3333
and i want to display in text box 99.33 so give me some idea about this how to convert it
Thanks
Posted

C#
try this,...

txtOutput.Text is ur textbox name and lblRate.Text is ur Float variable name

 txtOutput.Text = Math.Round(Convert.ToDecimal(lblRate.Text), 2).ToString();
 
Share this answer
 
TrRy this

double Val= Math.Round(99.3333, 2);
 
Share this answer
 
Hey
Check this.
Double  DblValue = 333.4567;
string StrValue = DblValue.ToString(".##");
//Answer will be 333.46.

Regards
 
Share this answer
 

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