Simplest C# code to poll a property?

后端 未结 8 1967
慢半拍i
慢半拍i 2021-01-03 06:31

I would like to know the simplest code for polling a property\'s value, to execute the code in its getter.
Currently I\'m using: instance.property.ToString();

8条回答
  •  盖世英雄少女心
    2021-01-03 07:24

    That sounds to me like a really terrible idea. Honestly, if you have logic in a getter that needs to be executed regularly, take it out of the getter and stick it in a method. I would hate to jump in and maintain code like that, and once I finally figured out why it was doing what it does I would refactor it.

提交回复
热议问题