Archive

Posts Tagged ‘Code Errors’

CodeRush code issues specific to constructors

September 29th, 2011 Comments off

A constructor is a special class member that is executed when a new object is created. There are two types of constructors: instance constructors and static constructors. Instance constructors are used to create and initialize instances of classes or structures. A static constructor is used to initialize a class itself. A static constructor is called automatically to initialize the class before the first instance is created or any static members are invoked.

Read more…

Code Issues specific to partial methods

September 9th, 2011 Comments off

A partial method declaration has two parts: the declaration itself and an implementation. Both parts of a partial method can be located in a single class or in different parts of a partial class. You can use partial methods in the code and implement them later if required. If you do not supply an implementation for a partial method, its signature is removed by the compiler.

Read more…

Code Issues specific to operators

September 9th, 2011 Comments off

An operator is a member that defines the meaning of applying a particular expression operator to instances of a class or structure. Three kinds of operators can be defined: unary operators, binary operators, and conversion operators. All operators have must be declared according to the language specification.

Read more…

Code Issues – Try statement without catch or finally

January 24th, 2011 Comments off

Cause:

This code issue shows an error if a ‘try’ statement doesn’t have a ‘catch’ or ‘finally’ statement. The try block must be completed, whether with catch or finally blocks.

The try block contains the guarded code that may cause the exception. The block is executed until an exception is thrown or it is completed successfully.

Read more…

Code Issues – Static constructors must be parameterless

January 24th, 2011 Comments off

Cause:

A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. Parameters are not allowed for static constructors.

Read more…

Code Issues – Interface expected

January 23rd, 2011 Comments off

This code issue shows an error when the structure is derived from a non-interface type. Structures can only inherit from other interfaces according to various language specifications.

Read more…

Code Issues – Property cannot have void type

January 22nd, 2011 Comments off

Cause:

A property is a member that provides a flexible mechanism to read, write, or compute the value of a field, thus it cannot have a void type. Properties are actually special methods called accessors (getter or setter) and they must have a specific non-void type according to most language specifications.

Read more…

Code Issues – Constructor must declare a body

January 21st, 2011 Comments off

Cause:

The Constructor must declare a body code issue shows an error if there is a constructor without a body. Constructors are similar to usual methods and whenever a class or struct is created, its constructor is called. Constructors should always declare its body to properly initialize a class or struct.

Read more…