static class disappear when reloading the same scene?

I have a static class:

public static class SharedBetweenScenes {
    public static string value;
}

In a script within a GameObject of the Scene A, I assign a value as follows: SharedBetweenScenes.value = "hi duby duby";

I load the Scene B. I can get the stored value doing: string value = SharedBetweenScenes.value;

Unfortunately, if a load the Scene A again and try to assign a different value: SharedBetweenScenes.value = "hello dude!"; the debugger says The name ‘SharedBetweenScenes.value’ does not exist in the current context.

Furthermore, if I load the Scene B, SharedBetweenScenes.value will have the old value of "hi duby duby" instead of the new value "hello dude!"

What is going on here? I also tried the singleton code proposed here with the exactly same problem.

@chelder
Because SharedBetweenScenes is not a MonoBehaviour class which means you can not attach it to a GameObject means you are leaving something out in your question leaving for some guess work.

If SharedBetweenScenes was created as a MonoBehaviour class then you could do something like in the Awake() function

DontDestroyOnLoad (transform.gameObject);

Since this does not seem to be the case you can look to do a few different things (you can try one or a combination of)

  1. You could try placing DontDestroyOnLoad within the class the uses that SharedBetweenScenes class.
  2. You could save and load your data using PlayerPrefs.
  3. Add [System.Serializable] above all class defines.