1. Only n digits must be retained.
Float F = 0.55555f;
Int I = (INT) (F * 100 );
F = (float) (I * 1.0)/100;
2. Keep n digits and round them
Decimal d = decimal. Round (decimal. parse ("0.55555"), 2 );
3. Keep n digits and round them
Math. Round (0.55555, 2)
4. Keep n digits and round them
Double dbdata = 0.55555;
String str1 = dbdata. tostring ("F2"); // FN retains N bits, rounded
5. Keep n digits and round them
String result = string. Format ("{0: N2}", 0.55555); // two digits
String result = string. Format ("{0: N3}", 0.55555); // three digits
6. Keep n digits and round them
Double S = 0.55555;
Result = S. tostring ("#0.00"); // a few digits are retained after a few zeros.
Or (calculate the area and perimeter of the circle)
Double S = convert. todouble (textbox1.text );
Double mianji = math. Pi * S * s;
Textbox2.text = mianji. tostring ("F3 ");
Double zhouchang = 2 * Math. Pi * s;
Textbox3.text = zhouchang. tostring ("F3 ");