Skip to main content

Members Declaration

  • 3 minutes to read

Templates library includes multiple templates for quick member declaration. These templates are available when the caret is inside a class body, but outside methods and properties. Most member declaration templates are complex and consist of two parts - the kind of member and its type. The table below shows examples of member declaration templates.

Member Kind void Boolean Integer Double String Object
Method m mb mi md ms mo
Property pb pi pd ps po
Auto-implemented Property ab ai ad as ao
Field fb fi fd fs fo

Note

If you need to force the creation of a static member, Uppercase the first letter of the required template. For example, the “Ms“ template creates the static method that returns a string. To access the full list of types or add a new one, refer to the Editor | All Languages | Template Name Variables options page.

The full list of member declaration templates is available in the code templates configuration options.

templates-page

If you prefer to have a printable copy of CodeRush code templates, download CodeRush Cheat Sheet.

Important

Visual Studio IntelliSense has priority over CodeRush templates. For information on how to prioritize a CodeRush template over Visual Studio IntelliSense, refer to the following topic section: Expand a Template Instead of Visual Studio IntelliSense.

Specify Default Scope for Declared Members

You can specify the default visibility modifier of generated members. For example, to generate a public static method:

Open the Editor | C# (Visual Basic) | Scope Options options page, set the default scope for methods to “Public”, and press Apply and OK to save the changes and close this page.

Options_Scope

Expand the “Ms“ template in the code editor.

Options_Scope

Types in Templates

The following tables list the main types you can use in templates.

System

Type Mnemonic
Boolean b
Byte by
Char c
DateTime d8
Decimal de
Double d
EventArgs ea
Exception x
Guid g
Int16 sh
Int32 i
Int64 l
IntPtr ip
Object o
Single si
String s
Type ty
UInt32 u

Generic Collections - one parameter

Type Mnemonic
BindingList bl
Collection c
Comparer cmp
EqualityComparer ec
ICollection ic
IEnumerable ie
LinkedList ll
LinkedListNode lln
List l
Queue q
ReadOnlyCollection roc
Stack k
XPCollection xcl

Generic Collections - two parameters

Type Mnemonic
Dictionary d
KeyValuePair kvp
SortedDictionary sd
SortedList sl

System.Data

Type Mnemonic
DataRow dr
DataRowView drv
DataSet ds
DataTable dt
DataView dv

Note

To access the full list of types or add a new one, refer to the Editor | All Languages | Template Name Variables options page.

See Also