尝试从 NumericUpDown 中的成本中减去设置

Trying to subtract setup from cost in a NumericUpDown

我正在尝试从 cost 中减去 setup。因此,我需要从 NumericUpDown 框中获取值并将其存储为一个整数,然后我可以使用该整数从 setup 中减去。

public partial class Form1 : Form
{
    int setup = 100;
    int finalcost;
    int cost;
    int priority;

    public Form1()
    {
        InitializeComponent();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        priority = trackBar1.Value;
        int cost = (int)numericUpDown1.Value;
        if (radioButton1.Checked)
        {

            finalcost = cost - setup;
            MessageBox.Show(finalcost.ToString());
        }
    }

NumericUpDown Maximum 属性 设置为高于 100。