Private 'set' in C# - having trouble wrapping my brain around it

Viewed 11063

I've seen a lot of example code written using something like (please forgive how horribly canned this is):

public class Test
{
   public object Thingy { get; private set; }
}

Unfortunately, these kinds of examples never really explain why 'set' is set as private. So, I'm just wondering if there's a good, common example that will illustrate to me why something like this would be used.

I sort of see it - the property can be run to process some extra logic in addition to setting that field. I'm just confused on how it would be invoked, and why this approach would be used rather than a generic setter method.

9 Answers
Related