C# - Getter 和 Setter 不保留值

C# - Getter and Setter dosen't keep the value

这是我的代码:

private int pressedMain = 1;

public int PressedMain
{
    get
    {
        return pressedMain;
    }

    set
    {
        pressedMain = value;
    }
}

然后我更改 pressedMain 的值:

pw.PressedMain++;

但是下面class我的值为1,为什么以及如何解决这个问题?

示例调用,控制台在此处打印 2

  public class Foo
    {
        private int pressedMain = 1;
        public int PressedMain
        {
            get
            {
                return pressedMain;
            }

            set
            {
                pressedMain = value;
            }
        }
    }
    class Program
    {

        static void Main(string[] args)
        {

            Foo foo = new Foo();
            foo.PressedMain++;

            Console.WriteLine(foo.PressedMain);

            Debugger.Break();
        }
    }