如何将它保留为decmail而不将其转换为字符串。我不希望有cahnge它作为我使用的值更改事件触发和文本十进制舍入,但保留十进制
if (!IsPostBack)
{
clientearningscic.Value = (decimal) _dal.getiandEData(_myuser.id, "clientearningscic") ;
otherincomeonecic.Text = _dal.getiandEData(_myuser.id, "otherincomethreecic").ToString("n2");
}
clientearningscic.ValueChanged += sumEarnings;
任何想法会帮我配发
private void sumEarnings(object sender, EventArgs e)
{
int total = Convert.ToInt16(clientearningscic.Text) + Convert.ToInt16(partnerearningscic.Text) + Convert.ToInt16(incomesupportcic.Text) + Convert.ToInt16(childtaxcreditcic.Text) + Convert.ToInt16(workingtaxcreditcic.Text) + Convert.ToInt16(pensioncic.Text) + Convert.ToInt16(childbenefitcic.Text) + Convert.ToInt16(chidlmaintenancecic.Text) + Convert.ToInt16(nondependantscontributioncic.Text) + Convert.ToInt16(otherincomeonecic.Text) + Convert.ToInt16(otherincometwocic.Text) + Convert.ToInt16(otherincomethreecic.Text);
lblTotalIcome.Text = total.ToString();
calcTotal();
}
不要将其保存为'int'但作为一个'double'代替。整数只支持整数,而'double'支持浮点数。 – Bobby
您是否尝试了Math.Round(),该函数将小数值和小数作为输入。 –
请接受答案 –