私はプログラミングが初めてで、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);
}
}
指示によると、メソッド c (DataEntry) からステートメントを取得するメソッド b (InputData) があるはずです... 指示は次のとおりです。
図 6-24 の InputMethodDemo プログラムの InputMethod() には、ユーザーにプロンプトを表示して整数値を取得する反復コードが含まれています。InputMethod() が別のメソッドを呼び出して作業を行うように、プログラムを書き直してください。書き直された InputMethod() には、次の 2 つのステートメントのみを含める必要があります。
one = DataEntry("最初");
two = DataEntry("秒");
新しいプログラムを InputMethodDemo2.cs として保存します。」
彼らが参照している InputMethodDemo は、2 つではなく 1 つのメソッド (InputMethod) のみを呼び出すことを除いて、同じプログラムです。
上記で参照したテキストは、「Microsoft® Visual C#® 2008、オブジェクト指向プログラミング入門、3e、Joyce Farrell」です。
アドバイス/ヘルプをいただければ幸いです。