1. NumberFormatInfo 設定小數位
NumberFormatInfo provider = new NumberFormatInfo();
provider.NumberDecimalDigits = intDecLength;
double strCashAmt = Convert.ToDouble(txtCashAmt.Text);
txtCashAmt.Text = strCashAmt.ToString("N", provider);
2. decimal.Round / Math.Round
decimal d = decimal.Round(decimal.Parse("0.55555"), 2); // 0.56
double r = Math.Round(0.55555, 2); // 0.56
3. ToString("fN") 格式
double dbdata = 0.55555;
string s = dbdata.ToString("f2"); // "0.56"
4. String.Format("{0:Nn}")
String.Format("{0:N2}", 0.55555); // "0.56"
String.Format("{0:N3}", 0.55555); // "0.556"
5. ToString("#0.00") 自訂格式
double s = 0.55555;
string result = s.ToString("#0.00"); // "0.56" (小數點後兩位)