It is a common occurrence wherein you may want to publicly expose a property's getter but internally restrict the setter. (The last refactoring challenge had a good use for this.) I regularly see people provide a publicly exposed property - with only a getter - and then add an internally available method for setting that property. Alternatively, as long as you're only "tightening" access, you can simply pre-append the appropriate access keyword in front of the get/set, accordingly. For example:
In the above code, the getter is publicly available while the setter is only internally available to the assembly in which it's defined. You can also use protected, private and logical combinations, if needed.
02-15-2007 4:55 PM