微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何进行抽象覆盖以将结果显示在Windows窗体的标签中?

如何解决如何进行抽象覆盖以将结果显示在Windows窗体的标签中?

这是我尝试过的:

 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()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。