StackOverflow on set of the static field

I am having trouble understanding and instantiating static variables.

As i remember, static variables are shared among all instances. so i have a class Player with a static field go_UI and setter

public static GameObject go_UI {set    {go_UI= value; }}

In a different class, i call the script directly and set the field value once

script_Player.go_UI = someGO;

This gives me a StackOverflow error.
Is it because i am trying to call the script directly and not the instance of an object ? Or am i setting a static field completely wrong?

the setter references itself
should have a different named backing field

What’s happening is, you are calling : go_UI = value, which is calling the ‘set’ property of go_UI -which, calls the set property of go_UI, which calls the set property of go_UI and so forth - thus resulting in a stackoverflow.

Since, you are not doing anything with ‘value’, you can have your code like so:

public static GameObject go_UI { set; }

This will automatically assign the value to the value go_UI.

Or, you can do it this way:

private static GameObject go;
public static GameObject go_UI {set { go = value; }}