Screen.orientation api error?

When testing out this code in the api:

https://docs.unity3d.com/ScriptReference/Screen-orientation.html

Error on this line:

Screen.orientation = ScreenOrientation.LandscapeLeft;

Error:

Assets/DeviceChange.cs(186,40): error CS0117: ScreenOrientation' does not contain a definition for LandscapeLeft’

Any ideas? I am copying the code from the api so I am confused why it doesn’t work.

You most likely named one of your classes “ScreenOrientation”. That will “hide” the ScreenOrientation enum type. It’s highly recommended to rename your type to something else. However if you want to keep it, you have to use the full type name:

 Screen.orientation = UnityEngine.ScreenOrientation.LandscapeLeft;