Back to Devexpress

Members Declaration

coderushforroslyn-115926-coding-assistance-code-templates-members-declaration.md

latest4.1 KB
Original Source

Members Declaration

  • Jan 31, 2023
  • 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 KindvoidBooleanIntegerDoubleStringObject
Methodmmbmimdmsmo
Propertypbpipdpspo
Auto-implemented Propertyabaiadasao
Fieldfbfifdfsfo

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.

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.

Expand the “ Ms “ template in the code editor.

Types in Templates

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

System

TypeMnemonic
Booleanb
Byteby
Charc
DateTimed8
Decimalde
Doubled
EventArgsea
Exceptionx
Guidg
Int16sh
Int32i
Int64l
IntPtrip
Objecto
Singlesi
Strings
Typety
UInt32u

Generic Collections - one parameter

TypeMnemonic
BindingListbl
Collectionc
Comparercmp
EqualityComparerec
ICollectionic
IEnumerableie
LinkedListll
LinkedListNodelln
Listl
Queueq
ReadOnlyCollectionroc
Stackk
XPCollectionxcl

Generic Collections - two parameters

TypeMnemonic
Dictionaryd
KeyValuePairkvp
SortedDictionarysd
SortedListsl

System.Data

TypeMnemonic
DataRowdr
DataRowViewdrv
DataSetds
DataTabledt
DataViewdv

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

Custom Template Creation