I'm trying to write some code to be as generic as possible, and as such want to make sure a function can alter the class's property in this manner:
public class Savesettings
{
public int alpha, beta, gamma, up, down, right, left;
public int MagicFunction(string value)
{
//if, say, the string is "alpha", return a reference to alpha etc...
}
}
Can I do this? I found Get name of property as a string but it's kinda too big brain for me. I think what I need is sorta like an inverse nameof, but that's not a very easy thing to search for apparently
EDIT: Sorry, I meant compile time.
Since it looks like what I asked for is impossible, can I instead use a public void MagicFunction(string value, int newvalue)
to set the property?