The original user control code in the accpected answer in this link :
not sure why it's crashing when trying to updating the SaveState it self.
CodePudding user response:
When you write
SaveState = value;
you call the setter.
When you do so in the setter's code, this causes infinite recursion - you assign to SaveState
in the setter, which calls the setter, which assigns to SaveState
, which calls the setter, which assigns to SaveState
, which calls the setter, and so forth forever, which is causing the IDE to crash.
The moral of the story: NEVER assign to the property inside the setter; ALWAYS assign to the backing field instead.