Assigning values to enum outside of function

Hi there, I can´t get this:

if I declare the variable currentScreen and assign a value to it in the same line (as the video shows), it´s ok, no errors.

But I wonder why if I declare the variable in one line, I can´t assign a value to that variable in the next line (I have to do it inside a function to get rid of errors):

B

I may be doing something wrong here, but I just don´t get it. Thanks!

Hello Alejandro.
i think you have two errors in you code , the one with the red underlining can be fixed if you copy what the instructor has done. Screen currentscreen = Screen.MainMenu; . and i think your right it needs to be in a function.

the error where you see 3 dotts under currentscreen
I was about to post about this , because i had the same problem but somehow today it was fixed .
i cannot say exactly what fixed it but i remember removing /reentering the code a couple times.
start by removing currentscreen = screen.password under Void Startgame and saving it.

Thank you very much for your kind response, I understand perfectly what you explained to me! Have a nice day :slight_smile:

Privacy & Terms