无效的标记'('在类,结构或接口成员声明中

时间:2013-10-26 23:11:00

标签: c#

        usersIncome = InputOutput.DisplayTaxDue(double userIncome, double taxDue, double taxRate, double flatRate);
        Console.WriteLine(" Your income is : {0:C} ", usersIncome );
        Console.WriteLine(" Your tax due is : {0:C} ", taxDue);    
        Console.WriteLine(" Your income is : {0} ", taxRate );
        Console.WriteLine(" Flat Rate is : {0} ",  flatRate);

每次打开和关闭括号后,我都会收到无效的令牌。

1 个答案:

答案 0 :(得分:3)

我怀疑你直接在一个类中编写了这段代码;指令只能出现在方法中,而不能直接出现在类中:

class YourClass
{
    public void YourMethod()
    {
        usersIncome = InputOutput.DisplayTaxDue(userIncome, taxDue, taxRate, flatRate);
        Console.WriteLine(" Your income is : {0:C} ", usersIncome );
        Console.WriteLine(" Your tax due is : {0:C} ", taxDue);    
        Console.WriteLine(" Your income is : {0} ", taxRate );
        Console.WriteLine(" Flat Rate is : {0} ",  flatRate);
    }
}

此外,当您调用方法时,不指定参数的类型;它们已在声明中指明。