私のコードの2つの問題:
1- Main() の Console.Writeline で奇妙な構文エラーが発生し、右中括弧 '}' が欠落していると思われます
2- Main() の後の最初のメソッドがわかりません。配列の要素を書き込む単純な void メソッドのはずですが、Visual Studio はエラーからクラスまたは名前空間のいずれかであると認識しているようです。
私が失敗した場所を誰か見つけられますか?
public static void Main(string[] args)
{
//static array for winning[6], empty for player[6], empty for matching[6]
int [] winning = new int [6] {2, 4, 6, 9, 1, 3};
int [] player = new int [6];
int [] matching = new int [6];
int inValue;
//Input loop
Console.WriteLine("Please enter six lotto numbers, between 1 and 9");
for (int i = 0; i < player.Length; i++)
{
inValue = Console.Read();
if (inValue < 1 || inValue > 9) //Validate for int 1-9
{
Console.WriteLine("Please enter a whole number between 1 and 9");
}
winning[i] = inValue;
}
//Output
Console.WriteLine("The winning numbers were:");
DisplayArray(int[] winning);
Console.WriteLine("Your numbers were:");
DisplayArrayContents(int[] player);
Console.WriteLine("You had " + MatchCount() + " matches.");
Console.WriteLine("Your matching numbers are:")
DisplayArrayContents(int[] matching);
Console.Read();
}
//Empty method to display arrays
static void DisplayArray(params int[] args)
{
for (int i = 0; i < args.Length; i++)
{
Console.Write({0} + "\t", array[i]);
}
Console.Write("\n");
}
編集:みんなありがとう!そこにあるいくつかの変数とメソッドの名前を変更するのを忘れていましたが、主な問題は欠落していました。Main() の引数として不要なデータ型。