我是编程新手,正在学习 C# 课程。当我尝试编写此程序时,我收到编译器错误 CS1001。
我阅读了编译器错误描述(下面的链接),但我真的不明白。我究竟做错了什么?
http://msdn.microsoft.com/en-us/library/b839hwk4.aspx
这是我的源代码:
using System;
public class InputMethodDemoTwo
{
public static void Main()
{
int first, second;
InputMethod(out first, out second);
Console.WriteLine("After InputMethod first is {0}", first);
Console.WriteLine("and second is {0}", second);
}
public static void InputMethod(out first, out second)
// The error is citing the line above this note.
{
one = DataEntry("first");
two = DataEntry("second");
}
public static void DataEntry(out int one, out int two)
{
string s1, s2;
Console.Write("Enter first integer ");
s1 = Console.ReadLine();
Console.Write("Enter second integer ");
s2 = Console.ReadLine();
one = Convert.ToInt32(s1);
two = Convert.ToInt32(s2);
}
}
根据说明,我应该有一个方法 b (InputData),它从方法 c (DataEntry) 中提取语句......以下是说明:
图 6-24 中 InputMethodDemo 程序中的 InputMethod() 包含提示用户和检索整数值的重复代码。重写程序,以便 InputMethod() 调用另一个方法来完成工作。重写后的 InputMethod() 只需要包含两个语句:
one = DataEntry("first");
two = DataEntry("second");
Save the new program as InputMethodDemo2.cs."
The InputMethodDemo they are referring to is the same program, except that it calls only one method (the InputMethod) instead of two.
The text I referred to above is "Microsoft® Visual C#® 2008, An Introduction to Object-Oriented Programming, 3e, Joyce Farrell"
Any advice/ help would be greatly appreciated.