I know the question isn't very clear, the thing I don't even know what words might exst to describe what I'm trying to do but this example should make it clearer.
Say this bit of code
public string Underscores;
public string Spaces
{
get => Underscores.Replace('_', ' ');
set => Underscores = value.Replace(' ', '_');
}
In this example, the value of Underscores is stored in memory but the value of Spaces is not and is instead generated on the fly when refered to. If the value of Spaces is changed, the value of Underscored changes accordingly. What I want to do is to extend this concept to structs and classes:
struct StringStruct
{
public string Value { get; set; }
}
...
public string Underscores;
public StringStruct Spaces
{
get => new StringStruct { Value = Underscores.Replace('_', ' ') };
set => UnderScores = value.Value.Replace(' ', '_') };
}
It works fine if I overwrite Spaces with a new StringStruct, but trying to change the value of Space's Value property results in a compiler error since it's not a variable. The same scenario but where StringStruct is a class causes no error but the change will be ignored and Underscores will remain the same.
The examples were made up for the sake of explanation and not what I'm actually trying to do.