【发布时间】:2014-02-19 23:12:48
【问题描述】:
我正在申请兴趣。我试图将总金额的利息金额精确到小数点后 2 位。我在代码中一直使用("N2"),除了标签中的一个区域外,它一直有效。
我使用标签在Radiobutton() 区域显示总金额,它仍然显示完整的数字eg.14.8282423432,而不是小数点后两位。有什么办法可以解决这个问题?谢谢。
public void ShowRates()
{
Amount = ((Form1)Owner).Amount;
WeekInterestRate = ((Form1)Owner).WeekInterestRate;
TwoWeekInterestRate = ((Form1)Owner).TwoWeekInterestRate;
MonthInterestRate = ((Form1)Owner).MonthInterestRate;
ThreeMonthInterestRate = ((Form1)Owner).ThreeMonthInterestRate;
WeekRateLabel.Text = WeekInterestRate.ToString("N2");
TwoWeekLabel.Text = TwoWeekInterestRate.ToString("N2");
MonthRateLabel.Text = MonthInterestRate.ToString("N2");
TMonthRateLabel.Text = ThreeMonthInterestRate.ToString("N2");
WeekPercent = (Amount * WeekInterestRate / 100);
WeekInterestAmount = ((WeekPercent / 365) * 7);
label6.Text = WeekInterestAmount.ToString("N2");
TwoWeekInterestPercent = (Amount * TwoWeekInterestRate / 100);
TwoWeekInterestAmount = ((TwoWeekInterestPercent / 365) * 14);
label7.Text = TwoWeekInterestAmount.ToString("N2");
MonthPercent = (Amount * MonthInterestRate / 100);
MonthInterestAmount = ((MonthPercent / 365) * 30);
label8.Text = MonthInterestAmount.ToString("N2");
ThreeMonthPercent = (Amount * ThreeMonthInterestRate / 100);
ThreeMonthInterestAmount = ((ThreeMonthPercent / 365) * 90);
label9.Text = ThreeMonthInterestAmount.ToString("N2");
}
public void Back()
{
Form1 f1 = new Form1();
f1.Show(this);
Hide();
}
public void RadioButtons()
{
if (radioButton2.Checked == true)
{
FinalAmount = (Amount + WeekInterestAmount);
FinalAmount.ToString("N2");
label10.Text = "Total Amount After 7 Days" + " " + "€" + FinalAmount;
RateChosen = WeekInterestRate;
InterestAmount = WeekInterestAmount;
Days = WEEK;
}
【问题讨论】:
标签: c#