C#“预期的错误需要帮助修复此错误 [英] C# " } expected" Error Need Help Fixing this error

查看:87
本文介绍了C#“预期的错误需要帮助修复此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我写了我的程序,我收到了这个错误。 }预期。



这是我的代码



Hello,

I wrote my program and I got this error. " } expected".

Here is my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Project_6
{
    public partial class Form1 : Form
    {
        const decimal basePay = 250m, quota = 1000m, rate = .15m;
        decimal sales, commissionValue, pay;
        public Form1()
        {
            InitializeComponent();
        }

        private void nameTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void salesAmountTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }
        private void commission()
            {
            if (sales >= quota)
            {
                commissionValue = sales * rate;
            }
            else
            {
                commissionValue = 0m;

    }
}

        private void payToolStripMenuItem_Click(object sender, EventArgs e)
        {
            sales = decimal.Parse(salesAmountTextBox.Text);
            commission();
               
            if (commissionValue > 0)
                {
                    commissionTextBox.Text = commissionValue.ToString("N2");
                }
                else
                {
                    commissionTextBox.Text = "";
                }
                pay = basePay + commissionValue;
                totalPayTextBox.Text = pay.ToString("N2");
                salesAmountTextBox.Text = sales.ToString ("N2");
            }

        }





我是c新手#请帮忙!我正在使用visual studio 2010.



I am very new to c# please help! I am using visual studio 2010.

推荐答案

最后再添加1个}



You have add 1 more } at the end

namespace Project_6
{


你需要在结尾添加一个}。
You need to add one more "}" at the end.


这篇关于C#“预期的错误需要帮助修复此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆