Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在属性网格中创建一个只读变量(int)。
有一点我不明白。
该变量没有设置,为什么它仍然允许我更改值(并且当它无法将值放入变量时下降)?
private int _myVar= 1; public int MyVar { get { return _myVar; } }
尝试ReadOnlyAttribute:
ReadOnlyAttribute
private int _myVar= 1; [ReadOnly(true)] public int MyVar { get { return _myVar; } }