【发布时间】:2010-10-23 21:29:49
【问题描述】:
我是编程新手,正在学习 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");
将新程序另存为 InputMethodDemo2.cs。"
他们所指的 InputMethodDemo 是同一个程序,只是它只调用一个方法(InputMethod)而不是两个。
我上面提到的文字是“Microsoft® Visual C#® 2008, An Introduction to Object-Oriented Programming, 3e, Joyce Farrell”
任何建议/帮助将不胜感激。
【问题讨论】:
标签: c# identifier method-signature