文字列として変換せずにデカールをどのように保持しますか?私はすべてのアイデアは私はあなたが整数として保存している小数点以下は四捨五入ですが、小数点以下を保持する
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();
}
を使用し、小数点以下の特定の数に値を四捨五入します。整数は整数だけをサポートするのに対して、 'double'は浮動小数点数をサポートします。 – Bobby
あなたはMath.Round()を試しましたか?関数は入力として小数の値と数を取得します。 –
回答を受け入れてください –