Declaring variables

cu2_s02_enumerating_our_game_states

#1

I can not understand one thing

here we set Screen and then currentScreen

Okay We need first word Screen for some purpose. The questions are:

  1. Why do we need it if (as I suppose) the function was determined in row above (with enum)
  2. If we need Screen there, why we don’t need it below?

Thank you!


#2

Hi,

What you are doing here is declaring a variable. In C#, in this example, the first word is the type, e.g. the data type of the variable, in this case its of type Screen.

The following word is the name of the variable, in this case currentScreen.

This would be the same for a string for exmaple;

string message;

message = "Hello World!";

Hope this helps.


#3

Sure, Rob! Thank you!


#4

No worries, you’re more than welcome. :slight_smile:


#5

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.