Properties backing field – What is it good for?

If you do this:

public int Capacity 
{ 
    get { return Capacity > 0 ? Capacity : -666; } 
    set { Capacity = value; } 
}

then your code will have an infinite recursion. It will never work. That’s because the getter for Capacity is referencing itself. Same thing goes for the setter.

Unless you are using automatic properties, you need a backing field

Leave a Comment