TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C# Coding Standard
Search

Rule:  7@603Checked automatically with code checker

Synopsis:Use a method rather than a property when this is more appropriate
Language:C#
Severity Level:9
Category:Object oriented


Description:

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.