In some cases a method is better than a property:
- The operation is a conversion, such as
Object.ToString.
- The operation is expensive enough that you want to communicate to the user that they should consider caching the result.
- Obtaining a property value using the get accessor would have an observable side effect.
- Calling the member twice in succession produces different results.
- The order of execution is important. See [7@601].
- The member is
static but returns a value that can be changed.
- The member returns a copy of an internal array or other reference type.
- Only a
set accessor would be supplied. Write-only properties tend to be confusing.
|