问题描述
这是我尝试过的:
public abstract double getTotalPrice();
和
public override double getTotalPrice()
{
this.discounted_price = (item_price * item_quantity) - (item_price * item_quantity * item_discount / 100);
return discounted_price;
}
private void button1_Click(object sender,EventArgs e)
{
discountedItem di = new discountedItem(textBox1.Text,Convert.Todouble(textBox2.Text),Convert.ToInt32(textBox3.Text),Convert.Todouble(textBox4.Text));
label10.Show(di.getTotalPrice().ToString());
}
当我单击按钮时,它将计算总价格,然后将其显示在标签中。 我一直在搜索,但是找不到确切的解决方案。
解决方法
使用
label10.Text = di.getTotalPrice().ToString();
代替Show()