我在编写简单程序时遇到了一些问题。我收到了大量的错误,说“无效的令牌”。使用枚举无效的令牌错误
该程序基本上要求2个整数并总结它们,但该程序需要以另一种方法调用。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AustinPDangeloJPA03
{
class Add
{
static void Main(string[] args)
{
double num1,
num2,
sum;
Console.Write("Enter the First integer: ");
num1 = int.Parse(Console.ReadLine());
//First Integer entered and storred
Console.Write("Enter the Second integer: ");
num2 = int.Parse(Console.ReadLine());
//Second Integer entered and storred
sum = Display(double a, double b);
//First and second numbers added together
Console.WriteLine(" {0} + {1} = {2} ",num1,num2,sum);
//displays the sum
//Instructs the user to press the Enter key to end the program
Console.WriteLine("Press the Enter key to terminate the program...");
Console.ReadLine();
}//Closes Main Method
static enum Display(a,b)
{
double c = a + b;
return c;
}//closes display method
}//Closes Class Add
}
你认为“静态枚举”是什么意思?无论你认为这意味着什么,这并不意味着什么。你能解释一下你的想法吗?我非常有兴趣了解人们对于代码意味着什么导致他们误入歧途的直觉,以便我们可以设计不会导致用户陷入这些陷阱的语言。谢谢! – 2010-09-27 23:28:10
@Eric:很好说。为了回答你的问题,我怀疑他认为'enum'是一个数字类型,或者他随机选择了一个关键字。 – SLaks 2010-09-27 23:30:02
“我得到了大量的错误,说”无效的标记“” - 向我们展示至少一些错误,以及它们引用的行号。 告诉我们你的代码中有一个“无效标记”*在某处*滥用了你要求帮助的同一个人! – abelenky 2010-09-27 23:35:39