I may be getting ahead of myself here, since I’m only on Lecture 19, but I was thinking of improving the NumberWizard game by allowing the user to select the range of numbers they could choose from, and automatically calculating the initial guess value as halfway between the two.
Keeping the 1-1000 range as a placeholder for now, I reasoned that you could express the initial guess value like this before the “void Start ()”:
int min = 1;
int max = 1000;
int guess = (max + min) * 0.5;
Instead, I’m get this error message instead:
“Assets/Scripts/NumberWizard.cs(9,22): error CS0236: A field initializer cannot reference the nonstatic field, method, or property `NumberWizard.max’”
Given that line 9 is the “int guess” statement, something’s clearly wrong with the language I’ve used there. What would the correct way to write that line be?