by sweisfeld via Shawn Weisfeld [MVP] on 6/16/2009 12:26:50 AM
Got a call today, someone was getting a stack dump every time they tried to assign a value to a property. Here is a screen print of the problem they were having. can you spot the problem?
If you said that the property is calling itself you get a gold star. What was happening is that every time we tried to set the Name property, it calls the Name property to set it, and that called the Name property, and that called the Name property, over and over again, till .NET stack dumped. We are missing a backing variable.
By backing the property with a private variable, it removes the infinite recursion. Since the variable itself is private nobody can see it, or can use it outside the class, they are forced to use the property, and all is right with the world again!
Original Post: Property Causing a Stack Dump
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.