Home > Code Generation > Declare Delegate CodeRush code provider

Declare Delegate CodeRush code provider

June 1st, 2012

A delegate is a special kind of object that holds a reference to a method. Once a delegate is assigned a method, it behaves exactly like that method. It can have parameters and a return value. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object.

CodeRush provides the Declare Delegate code provider that is available on references that refer a delegate which is not declared yet, for example:

CodeRush Declare Delegate on simple reference

the following result will be produced after the code provider is applied:

CodeRush Declare Delegate on simple reference result

Another example:

CodeRush Declare Delegate on Event Handler

the following delegate will be generated:

CodeRush Declare Delegate on Event Handler result

—–
Products: CodeRush Pro
Versions: 11.2 and up
VS IDEs: 2008 and up
Updated: Jun/01/2012
ID: C165

Similar Posts: