Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无效令牌';(';在类、结构或接口成员声明中)_C# - Fatal编程技术网

C# 无效令牌';(';在类、结构或接口成员声明中)

C# 无效令牌';(';在类、结构或接口成员声明中),c#,C#,每次打开和关闭括号后,我都会得到无效的标记。我怀疑您直接在类中编写了此代码;指令只能出现在方法中,不能直接出现在类中: usersIncome = InputOutput.DisplayTaxDue(double userIncome, double taxDue, double taxRate, double flatRate); Console.WriteLine(" Your income is : {0:C} ", usersIncome );

每次打开和关闭括号后,我都会得到无效的标记。

我怀疑您直接在类中编写了此代码;指令只能出现在方法中,不能直接出现在类中:

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

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

在将参数传递到
displaytasdue()之前,不需要类型名称
。例如,
double userIncome,
是无效语法。传递参数时,您没有重新指定类型。您是在方法中编写此代码,还是直接在类中编写此代码?
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);
    }
}