I get the error below when I try to run the application I am sure its something simple but I dont see it. What I am trying to do it when I click a button I have labeled Play. I
Well, your code doesn't match the error, but look at this:
private void btnPlay_Click(object sender, EventArgs e)
{
RandomNumber();
}
private void RandomNumber(int min, int max)
{
int num = new Random().Next(min, max);
lblPickFive_1.Text = num.ToString();
}
RandomNumber
has two parameters, min
and max
. You haven't specified any in the call inside btnPlay_Click
. That's what the compiler is complaining about. Change the call to something like:
RandomNumber(5, 10);
Even when that's fixed, you shouldn't create a new instance of Random
each time. As it happens, it's unlikely to cause problems in this particular case as it's triggered by a user action, but you should read my article on random numbers to see what the problem is and how to avoid it.