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

Category: Object lifecycle

Synopsis:Object lifecycle


Description:

Coding Rules

NameCheckedSynopsis
5@101 Declare and initialize variables close to where they are used
5@102 If possible, initialize variables at the point of declaration
5@105 Use a const field to define constant values
5@106 Use a public static readonly field to define predefined object instances
5@107 Set a reference field to null to tell the garbage collector that the object is no longer needed
5@108 Checked automatically with code checker Do not 'shadow' a name in an outer scope
5@111 Checked automatically with code checker Avoid implementing a finalizer
5@112 Checked automatically with code checker Provide a method that will cause the finalizer not to be called
5@113 Checked automatically with code checker Implement IDisposable if a class uses unmanaged resources, owns disposable objects or subscribes to other objects
5@114 Checked automatically with code checker Do not access any reference type members in the finalizer
5@116 Always document when a member returns a copy of a reference type or array
5@117 Properties, methods and arguments representing strings or collections should never be null
5@118 A virtual method may only be called if an object is fully constructed
5@119 Checked automatically with code checker Return an IEnumerable<T> or ICollection<T> instead of a concrete collection class
5@120 Checked automatically with code checker Avoid using named arguments
5@121 Checked automatically with code checker Don't use "using" variables outside the scope of the "using" statement
5@122 Checked automatically with code checker Avoid empty finalizers