I wanted to use nameof() to get variable name, to later use it in something like an Undo/Redo method. In my specific case I have 2 different classes, which I want to use the Undo/Redo function.
My first thought was to push changes to a stack in a format. However, will I be able to use it in the code itself? Is something like the code below possible?
public class Person
{
public string Name;
public Person(string Name)
{
this.Name = Name;
}
}
class Program
{
static void Main(string[] args)
{
var person = new Person("Pete");
var nameProperty = nameof(person.Name);
person.nameProperty = "Luke";
}
}