Two problems with my code:
1- I'm getting weird syntax errors with Console.Writeline in Main(), and I think I have a missing right curly brace '}'
2- I can't seem to figure out my first method after Main(). It's just supposed to be a simple void method to write the elements of an array, but Visual Studio seems to think it's either a class or namespace from the errors.
Can anyone spot where I screwed up?
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");
}
Edit: Thanks everyone! I forgot to rename some variables and methods in there, but the main problem was a missing ; and unnecessary data types as arguments in Main().
You should not pass a type along with the parameter when you call a method. So for example
DisplayArray(int[] winning);should be justDisplayArray(winning);Fix all those errors and you should be fine.