ReSharper 8.0 Web Help

ReSharper | Templates Explorer | Live Templates

This topic lists all predefined Live templates in ReSharper 8.0.

Live templates represent code fragments that can be quickly inserted into your code. The code of the template can be a short expression, a complete construct, or even an entire class or method. Each live template is identified by a Shortcut - a short string of characters such as itar (abbreviation of "Iterate an array"),  thr (for "throw new") - that you can type right in the editor to invoke the template. For more information, see Creating Source Code Using Live Templates.

Template Description

Global

ctx Current file context
nguid Insert new GUID

C#

join Join clause in language integrated query
from Language-Integrated Query
foreach foreach block
itdic Iterate a Dictionary
itdg Iterate a Dictionary<K, V>
itli Iterate a IList<T>
itar Iterate an array
ital Iterate an ArrayList
ritar Iterate an array in inverse order
for Simple "for" loop
toar Convert an ArrayList to array
sfc Safely cast variable
psvm The "Main" method declaration
outv Print value of a variable
out Print a string
asrt Make an assertion
asrtn Assert expression not null
thr throw new
pci public const int
pcs public const string
psr public static readonly
prop Property
ear Create an empty array
hal ASP.NET MVC Html.ActionLink
ua ASP.NET MVC Url.Action
rta ASP.NET Controller RedirectToAction
attachedProperty Attached property
dependencyProperty Dependency property

VB.NET

foreach For Each block
itar Iterate an array
itdg Iterate generic dictionary System.Collections.IDictionary(Of K, V)
itli Iterate generic System.Collections.Generic.IList(Of T)
for Simple "For" loop
ritar Iterate array in reverse order
Dim Declare a variable
asrt Make an assertion
out Print a string
outv Print value of an expression
pssm Public Shared Sub Main
sfc Safely cast a variable
sub Subroutine declaration
fun Function declaration
dc DirectCast clause
tc TryCast clause
ct CType clause
ByRef ByRef parameter
ByVal ByVal parameter
sel Select case statement
attachedProperty Attached property
dependencyProperty Dependency property

XML

t Create tag
tc Create closed tag
a Create tag attribute

HTML

<script Create script tag
t Create tag
tc Create closed tag
a Create tag attribute

ASP.NET

t Create ASP.NET tag
tc Create closed tag
<asp:HyperLink ASP.NET Hyperlink

RESX

d Create resource entry

JavaScript

fun Create JavaScript function
itar Iterate an array

Razor

@inherits Razor inherits directive
@model Razor model directive
@section Razor section

Global

Template Details
ctx

Current file context

Scope everywhere

Body

$CTX$

Parameters

  • CTX - Provides list of items describing current context. This includes file name, containing type name, namespace name, etc.

This could be useful:

  • In string literals that contain references to the current context, i.e. Logger.LogError("Cannot find action ActionNameDerivedFromContext");
  • As an alternative to code completion where IntelliSense doesn't work properly - for example, in comments when documenting a member with a long name (see example below).

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__No_Language__ctx__before
Expansion options
Reference__Options__Templates__Live_Templates__Predefined__No_Language__ctx__expansion

nguid

Insert new GUID

Scope everywhere

Body

$GUID$

Parameters

  • GUID - Generates new Globally Unique Identifier (GUID)

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__No_Language__nguid__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__No_Language__nguid__after

C#

Template Details
join

Join clause in language integrated query

Scope C# 2.0+ queries

Body

join $NAME$ in $COL$ on $EXPR1$ equals $EXPR2$ $END$

Parameters

  • COL - Suggests variables of the specified type.
  • NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • EXPR1 - no macro
  • EXPR2 - no macro
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__join__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__join__after

from

Language-Integrated Query

Scope C# 3.0+ expressions, C# 3.0+ queries

Body

from $VAR$ in $COLLECTION$ $END$

Parameters

  • COLLECTION - Suggests variables of the specified type.
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__from__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__from__after

foreach

foreach block

Scope C# 2.0+ statements

Body

foreach ($TYPE$ $VARIABLE$ in $COLLECTION$)
{
  $END$
}

Parameters

  • COLLECTION - Suggests visible variable that can be enumerated (that is, used in foreach loop as collection)
  • TYPE - Suggest type for a new variable declared in the template
  • VARIABLE - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__foreach__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__foreach__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

itdic

Iterate a Dictionary

Scope C# 2.0+ statements

Body

foreach (System.Collections.DictionaryEntry $ENTRY$ in $DICT$)
{
  $KEYTYPE$ $KEY$ = $CASTKEY$$ENTRY$.Key;
  $VALTYPE$ $VAL$ = $CASTVALUE$$ENTRY$.Value;
  $END$
}

Parameters

  • DICT - Suggests variables of the specified type.
  • ENTRY - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • KEYTYPE - Analyzes code and guesses type of key of a dictionary collection.
  • KEY - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • CASTKEY - Inserts (if required) cast to the type which is expected at the left side of assignment expression.
  • VALTYPE - Analyzes code and guesses type of value of a dictionary collection.
  • VAL - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • CASTVALUE - Inserts (if required) cast to the type which is expected at the left side of assignment expression.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itdic__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itdic__after

The template generates a foreach block which iterates over a System.Collections.IDictionary collection. Unlike itdg, it provides fully-qualified type name for iterator variable in the loop condition and performs type casts over the key and the value of a dictionary element in the loop body. Includes two customizable statements in the loop body with two variables holding the key and the value of a dictionary element.

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

itdg

Iterate a Dictionary<K, V>

Scope C# 2.0+ statements

Body

foreach ($DETYPE$ $ENTRY$ in $DICT$)
{
  $KEYTYPE$ $KEY$ = $ENTRY$.Key;
  $VALTYPE$ $VAL$ = $ENTRY$.Value;
  $END$
}

Parameters

  • DICT - Suggests variables of the specified type.
  • ENTRY - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • DETYPE - Suggest type for a new variable declared in the template
  • KEYTYPE - Suggest type for a new variable declared in the template
  • KEY - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • VALTYPE - Suggest type for a new variable declared in the template
  • VAL - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itdg__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itdg__after

The template generates a foreach block which iterates over a System.Collections.Generic.IDictionary collection. Includes two customizable statements in the loop body with two variables holding the key and the value of a dictionary element.

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

itli

Iterate a IList<T>

Scope C# 2.0+ statements

Body

for (int $INDEX$ = 0; $INDEX$ < $LIST$.Count; $INDEX$++)
{
  $TYPE$ $ITEM$ = $LIST$[$INDEX$];
  $END$
}

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point.
  • LIST - Suggests variables of the specified type.
  • TYPE - Suggest type for a new variable declared in the template
  • ITEM - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itli__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itli__after

The template generates a for loop which iterates over an instance of System.Collections.IList. Includes a customizable statement in the loop body with a variable holding container elements.

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

itar

Iterate an array

Scope C# 2.0+ statements

Body

for (int $INDEX$ = 0; $INDEX$ < $ARRAY$.Length; $INDEX$++)
{
  $TYPE$ $VAR$ = $ARRAY$[$INDEX$];
  $END$
}

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point.
  • ARRAY - Suggests variable which type is array type
  • TYPE - Suggest type for a new variable declared in the template
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itar__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__itar__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

ital

Iterate an ArrayList

Scope C# 2.0+ statements

Body

for (int $INDEX$ = 0; $INDEX$ < $ARRAY$.Count; $INDEX$++)
{
  $TYPE$ $VAR$ = ($TYPE$)$ARRAY$[$INDEX$];
  $END$
}

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point.
  • ARRAY - Suggests variables of the specified type.
  • TYPE - Analyzes code and guesses type of element of a collection.
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__ital__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__ital__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

ritar

Iterate an array in inverse order

Scope C# 2.0+ statements

Body

for (int $INDEX$ = $ARRAY$.Length - 1; $INDEX$ >= 0; $INDEX$--)
{
  $TYPE$ $VAR$ = $ARRAY$[$INDEX$];
  $END$
}

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point.
  • ARRAY - Suggests variable which type is array type
  • TYPE - Suggest type for a new variable declared in the template
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__ritar__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__ritar__after

The template generates a for loop for iterating over an array in reverse order. Includes a customizable statement in the loop body with a variable holding container elements.

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

for

Simple "for" loop

Scope C# 2.0+ statements

Body

for (int $INDEX$ = 0; $INDEX$ < $UPPER$; $INDEX$++)
{
  $END$
}

Parameters

  • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point.
  • UPPER - no macro
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__loop__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Iteration__loop__after

After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

toar

Convert an ArrayList to array

Scope C# 2.0+ expressions

Body

($TYPE$[])$ARRAYLIST$.ToArray(typeof($TYPE$))

Parameters

  • ARRAYLIST - Suggests variables of the specified type.
  • TYPE - Guess element type if a collection type is expected at this point

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__toar__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__toar__after

The template generates a code fragment that copies the elements of System.Collections.ArrayList to an array using the ToArray() method. It is most efficiently used where the required element type can be determined from the context.

sfc

Safely cast variable

Scope C# 2.0+ statements

Body

$VARTYPE$ $VAR$ = $VAR1$ as $TYPE$;

if ($VAR$ != null)
{
  $END$
}

Parameters

  • VAR1 - Suggests variables of the specified type.
  • TYPE - no macro
  • VARTYPE - Suggest type for a new variable declared in the template
  • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__sfc__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__sfc__after

psvm

The "Main" method declaration

Scope C# 2.0+ type members

Body

public static void Main( string[] args )
{
  $END$
}

Parameters

  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__psvm__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__psvm__after

outv

Print value of a variable

Scope C# 2.0+ statements

Body

System.Console.Out.WriteLine("$EXPR$ = {0}", $EXPR$);

Parameters

  • EXPR - Suggests variables of the specified type.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__outv__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__outv__after

ReSharper automatically suggests a list of all variables in the current scope and, by default, selects the most recently declared one. The descriptive text string (s = in the example above) is automatically synchronized with the name of the selected variable.

out

Print a string

Scope C# 2.0+ statements

Body

System.Console.Out.WriteLine("$END$");

Parameters

  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__out__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__out__after

asrt

Make an assertion

Scope C# 2.0+ statements

Body

System.Diagnostics.Debug.Assert($END$);

Parameters

  • END - The caret position after the template is applied.

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__asrt__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__asrt__after

This template calls the Debug.Assert method, which is used for debugging purposes. After the template expanded, the caret moves between the parentheses so that you can specify a condition.

asrtn

Assert expression not null

Scope C# 2.0+ statements

Body

System.Diagnostics.Debug.Assert($EXPR$ != null, "$MESSAGE$");

Parameters

  • EXPR - no macro
  • MESSAGE - no macro

Before expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__asrtn__before
After expansion
Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__asrtn__after

The template inserts the Debug.Assert method, which checks a condition and displays a message if the condition is false.

thr

throw new

Scope C# 2.0+ statements

Body

throw new 

    Before expansion
    Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__thr__before
    After expansion
    Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__thr__after

    pci

    public const int

    Scope C# 2.0+ type members

    Body

    public const int 

      Before expansion
      Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__pci__before
      After expansion
      Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__pci__after

      pcs

      public const string

      Scope C# 2.0+ type members

      Body

      public const string 

        Before expansion
        Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__pcs__before
        After expansion
        Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__pcs__after

        psr

        public static readonly

        Scope C# 2.0+ type members

        Body

        public static readonly 

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__psr__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__psr__after

          prop

          Property

          Scope C# 2.0+ type members

          Body

          public $TYPE$ $NAME$ { get; set; }

          Parameters

          • TYPE - no macro
          • NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__prop__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__prop__after

          ear

          Create an empty array

          Scope C# 2.0+ statements

          Body

          $TYPE$[] $NAME$ = new $TYPE$[] {};

          Parameters

          • TYPE - no macro
          • NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__ear__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__ear__after

          hal

          ASP.NET MVC Html.ActionLink

          Scope C# 2.0+ expressions

          Body

          Html.ActionLink("$TEXT$", "$ACTION$", "$CONTROLLER$")

          Parameters

          • CONTROLLER - Show completion list with available ASP.NET MVC Controllers at the point where the variable is evaluated
          • ACTION - Show completion list with available ASP.NET MVC Actions at the point where the variable is evaluated
          • TEXT - no macro

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__hal__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__hal__after

          ua

          ASP.NET MVC Url.Action

          Scope C# 2.0+ expressions

          Body

          Url.Action("$ACTION$", "$CONTROLLER$")

          Parameters

          • CONTROLLER - Show completion list with available ASP.NET MVC Controllers at the point where the variable is evaluated
          • ACTION - Show completion list with available ASP.NET MVC Actions at the point where the variable is evaluated

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__ua__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__ua__after

          rta

          ASP.NET Controller RedirectToAction

          Scope C# 2.0+ expressions

          Body

          RedirectToAction("$ACTION$", "$CONTROLLER$")

          Parameters

          • CONTROLLER - Show completion list with available ASP.NET MVC Controllers at the point where the variable is evaluated
          • ACTION - Show completion list with available ASP.NET MVC Actions at the point where the variable is evaluated

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__rta__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__CSharp__Other__rta__after

          attachedProperty

          Attached property

          Scope C# 2.0+ type members

          Body

          public static readonly DependencyProperty $propertyName$Property = 
            DependencyProperty.RegisterAttached("$propertyName$", typeof ($propertyType$), typeof ($containingType$), new PropertyMetadata(default($propertyType$)));
          
          public static void Set$propertyName$($UIElement$ $element$, $propertyType$ value)
          {
            $element$.SetValue($propertyName$Property, value);
          }
          
          public static $propertyType$ Get$propertyName$($UIElement$ $element$)
          {
            return ($propertyType$) $element$.GetValue($propertyName$Property);
          }

          Parameters

          • propertyName - no macro
          • propertyType - Show basic code completion list at the point where the variable is evaluated
          • containingType - Evaluates to short name of the most inner containing type.
          • UIElement - no macro
          • element - no macro

          The template creates an attached property with required get and set procedures.

          dependencyProperty

          Dependency property

          Scope C# 2.0+ type members

          Body

          public static readonly System.Windows.DependencyProperty $propertyName$Property =
            System.Windows.DependencyProperty.Register("$propertyName$", typeof ($propertyType$), typeof ($containingType$), new PropertyMetadata(default($propertyType$)));
          
          public $propertyType$ $propertyName$
          {
            get { return ($propertyType$) GetValue($propertyName$Property); }
            set { SetValue($propertyName$Property, value); }
          }

          Parameters

          • propertyName - no macro
          • propertyType - no macro
          • containingType - Evaluates to short name of the most inner containing type.

          VB.NET

          Template Details
          foreach

          For Each block

          Scope VB.NET 8+ statements

          Body

          For Each $VAR$ As $TYPE$ In $COL$ 
            $END$
          Next

          Parameters

          • COL - Suggests visible variable that can be enumerated (that is, used in foreach loop as collection)
          • TYPE - Analyzes code and guesses type of element of a collection.
          • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__foreach__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__foreach__after

          After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

          itar

          Iterate an array

          Scope VB.NET 8+ statements

          Body

          For $VAR$ As Integer = 0 To $ARRAY$.Length - 1
            Dim $ELEMENT$ As $TYPE$ = $ARRAY$($VAR$)
            $END$
          Next

          Parameters

          • ARRAY - Suggests variable which type is array type
          • VAR - Suggests non-used name which can be used for an index variable at the evaluation point.
          • TYPE - Analyzes code and guesses type of element of a collection.
          • ELEMENT - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itar__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itar__after

          After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

          itdg

          Iterate generic dictionary System.Collections.IDictionary(Of K, V)

          Scope VB.NET 8+ statements

          Body

          For Each $ITER$ As $ITERTYPE$ In $DIC$
            Dim $KEY$ As $KEYTYPE$ = $ITER$.Key
            Dim $VALUE$ As $VALUETYPE$ = $ITER$.Value
            $END$
          Next  
            

          Parameters

          • DIC - Suggests variables of the specified type.
          • ITERTYPE - Analyzes code and guesses type of element of a collection.
          • ITER - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • KEYTYPE - Analyzes code and guesses type of key of a dictionary collection.
          • KEY - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • VALUETYPE - Analyzes code and guesses type of value of a dictionary collection.
          • VALUE - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itdg__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itdg__after

          The template generates a For Each block which iterates over a System.Collections.IDictionary collection. Includes two customizable statements in the loop body with two variables holding the key and the value of a dictionary element.

          After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

          itli

          Iterate generic System.Collections.Generic.IList(Of T)

          Scope VB.NET 8+ statements

          Body

          For $INDEX$ As Integer = 0 To $LIST$.Count - 1
            Dim $ELEM$ As $TYPE$ = $LIST$($INDEX$)
            $END$
          Next

          Parameters

          • LIST - Suggests variables of the specified type.
          • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point.
          • TYPE - Analyzes code and guesses type of element of a collection.
          • ELEM - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itli__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__itli__after

          Generates a For loop which iterates over an instance of System.Collections.IList.

          After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

          for

          Simple "For" loop

          Scope VB.NET 8+ statements

          Body

          For $VAR$ As Integer = 0 To $MAX$
            $END$
          Next

          Parameters

          • VAR - Suggests non-used name which can be used for an index variable at the evaluation point.
          • MAX - Evaluates to the specified constant value.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__for__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__for__after

          After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

          ritar

          Iterate array in reverse order

          Scope VB.NET 8+ statements

          Body

          For $VAR$ As Integer = $ARR$.Length - 1 To 0 Step -1
            Dim $ELEM$ As $TYPE$ = $ARR$($VAR$)
            $END$
          Next

          Parameters

          • ARR - Suggests variable which type is array type
          • VAR - Suggests non-used name which can be used for an index variable at the evaluation point.
          • TYPE - Analyzes code and guesses type of element of a collection.
          • ELEM - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__ritar__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Iteration__ritar__after

          After you specify the parameters, the caret is positioned so that you can continue coding the loop body.

          Dim

          Declare a variable

          Scope VB.NET 8+ statements, VB.NET 8+ type members

          Body

          Dim $VAR$ As $TYPE$

          Parameters

          • TYPE - no macro
          • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dim__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dim__after

          asrt

          Make an assertion

          Scope VB.NET 8+ statements

          Body

          System.Diagnostics.Debug.Assert($END$)

          Parameters

          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__asrt__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__asrt__after

          The template calls the System.Diagnostics.Debug.Assert() method. After the template expands, the caret moves between the parentheses so that you can specify a condition.

          out

          Print a string

          Scope VB.NET 8+ statements

          Body

          System.Console.WriteLine("$END$")

          Parameters

          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__out__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__out__after

          outv

          Print value of an expression

          Scope VB.NET 8+ statements

          Body

          System.Console.WriteLine("$EXPR$ = {0}", $EXPR$)

          Parameters

          • EXPR - Suggests variables of the specified type.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__outv__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__outv__after

          pssm

          Public Shared Sub Main

          Scope VB.NET 8+ type members

          Body

          Public Shared Sub Main
            $END$
          End Sub

          Parameters

          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__pssm__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__pssm__after

          sfc

          Safely cast a variable

          Scope VB.NET 8+ statements

          Body

          Dim $VAR$ As $TYPE$ = TryCast($EXPR$, $TYPE$)
          
          If $VAR$ IsNot Nothing Then
            $END$
          End If

          Parameters

          • EXPR - Suggests variables of the specified type.
          • TYPE - no macro
          • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sfc__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sfc__after

          sub

          Subroutine declaration

          Scope VB.NET 8+ type members

          Body

          Sub $NAME$()
            $END$
          End Sub

          Parameters

          • NAME - no macro
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sub__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sub__after

          fun

          Function declaration

          Scope VB.NET 8+ type members

          Body

          Function $NAME$() As $TYPE$
            $END$
          End Function

          Parameters

          • NAME - no macro
          • TYPE - no macro
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__fun__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__fun__after

          dc

          DirectCast clause

          Scope VB.NET 8+ expressions

          Body

          DirectCast($EXPR$, $TYPE$)

          Parameters

          • EXPR - no macro
          • TYPE - no macro

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dc__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dc__after

          Note

          For more details on CType vs. DirectCast, see Visual Basic Language Reference: DirectCast.

          tc

          TryCast clause

          Scope VB.NET 8+ expressions

          Body

          TryCast($EXPR$, $TYPE$)

          Parameters

          • EXPR - no macro
          • TYPE - no macro

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__tc__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__tc__after

          ct

          CType clause

          Scope VB.NET 8+ expressions

          Body

          CType($EXPR$, $TYPE$)

          Parameters

          • EXPR - no macro
          • TYPE - no macro

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__ct__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__ct__after

          Note

          For more details on CType vs. DirectCast, see Visual Basic Language Reference: DirectCast.

          ByRef

          ByRef parameter

          Scope VB.NET 8+ method parameters

          Body

          ByRef $PARAM_NAME$ As $PARAM_TYPE$

          Parameters

          • PARAM_TYPE - no macro
          • PARAM_NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byref__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byref__after

          ByVal

          ByVal parameter

          Scope VB.NET 8+ method parameters

          Body

          ByVal $PARAM_NAME$ As $PARAM_TYPE$

          Parameters

          • PARAM_TYPE - no macro
          • PARAM_NAME - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byval__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__byval__after

          sel

          Select case statement

          Scope VB.NET 8+ statements

          Body

          Select Case $expression$
              $END$
          End Select

          Parameters

          • expression - Show smart code completion list at the point where the variable is evaluated
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sel__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__sel__after

          attachedProperty

          Attached property

          Scope VB.NET 8+ type members

          Body

          Public Shared ReadOnly $propertyName$Property As System.Windows.DependencyProperty = System.Windows.DependencyProperty.RegisterAttached("$propertyName$", GetType ($propertyType$), GetType ($containingType$), new System.Windows.PropertyMetadata(Nothing))
          
          Public Shared Function Get$propertyName$ (ByVal $element$ As $UIElement$) As $propertyType$
            Return DirectCast ($element$.GetValue ($propertyName$Property), $propertyType$)
          End Function
          
          Public Shared Sub Set$propertyName$ (ByVal $element$ As $UIElement$, ByVal value As $propertyType$)
            $element$.SetValue ($propertyName$Property, value)
          End Sub
          

          Parameters

          • propertyType - Show basic code completion list at the point where the variable is evaluated
          • propertyName - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • containingType - Evaluates to short name of the most inner containing type.
          • UIElement - Show basic code completion list at the point where the variable is evaluated
          • element - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__attachedProperty__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__attachedProperty__after

          dependencyProperty

          Dependency property

          Scope VB.NET 8+ type members

          Body

          Public Shared ReadOnly $propertyName$Property As System.Windows.DependencyProperty = System.Windows.DependencyProperty.Register("$propertyName$", GetType ($propertyType$), GetType ($containingType$), new System.Windows.PropertyMetadata(Nothing))
          
          Public Property $propertyName$ As $propertyType$
            Get
              Return DirectCast (GetValue($propertyName$Property), $propertyType$)
            End Get
            Set
              SetValue($propertyName$Property, value)
            End Set
          End Property

          Parameters

          • propertyType - Show basic code completion list at the point where the variable is evaluated
          • propertyName - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • containingType - Evaluates to short name of the most inner containing type.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dependencyProperty__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__VB.NET__Other__dependencyProperty__after

          XML

          Template Details
          t

          Create tag

          Scope XML tags

          Body

          <$TAG$>$END$</$TAG$>

          Parameters

          • TAG - Suggests XML tag name used in current document
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__XML__t__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__XML__t__after

          tc

          Create closed tag

          Scope XML tags

          Body

          <$TAG$ $END$/>

          Parameters

          • TAG - Suggests XML tag name used in current document
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__XML__tc__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__XML__tc__after

          a

          Create tag attribute

          Scope XML attributes

          Body

          $ATTR$="$END$"

          Parameters

          • ATTR - Suggests XML attribute name used in the same tags in current document
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__XML__a__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__XML__a__after

          HTML

          Template Details
          <script

          Create script tag

          Scope HTML and similar tags

          Body

          <script type="$attributeValue$">$END$</script>

          Parameters

          • attributeValue - Suggest attribute value for current html tag attribute
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__script__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__script__after

          t

          Create tag

          Scope HTML tags

          Body

          <$TAG$>$END$</$TAG$>

          Parameters

          • TAG - Suggest tag name used in current document
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__t__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__t__after

          tc

          Create closed tag

          Scope HTML tags

          Body

          <$TAG$ $END$/>

          Parameters

          • TAG - Suggest tag name used in current document
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__tc__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__tc__after

          a

          Create tag attribute

          Scope HTML and similar attributes

          Body

          $ATTR$="$END$"

          Parameters

          • ATTR - Suggests attribute name used in the same tags in current document
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__attr__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__HTML__attr__after

          ASP.NET

          Template Details
          t

          Create ASP.NET tag

          Scope ASP.NET tags

          Body

          <$TAG$ $RUNATSERVER$>$END$</$TAG$>

          Parameters

          • TAG - Suggest tag name used in current document
          • RUNATSERVER - Insert runat="server" if server-side tag selected
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__ASP.NET__t__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__ASP.NET__t__after

          tc

          Create closed tag

          Scope ASP.NET tags

          Body

          <$TAG$ $RUNATSERVER$$END$/>

          Parameters

          • TAG - Suggest tag name used in current document
          • RUNATSERVER - Insert runat="server" if server-side tag selected
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__ASP.NET__tc__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__ASP.NET__tc__after

          <asp:HyperLink

          ASP.NET Hyperlink

          Scope ASP.NET tags

          Body

          <asp:HyperLink runat="server" NavigateUrl="$LINK$" Text="$TEXT$" />

          Parameters

          • LINK - no macro
          • TEXT - no macro

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__ASP.NET__aspHyperLink__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__ASP.NET__aspHyperLink__after

          RESX

          Template Details
          d

          Create resource entry

          Scope .resx roots

          Body

          <data name="$name$">
              <value>$END$</value>
            </data>

          Parameters

          • name - Suggest tag name used in current document
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__Resx__d__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__Resx__d__after

          JavaScript

          Template Details
          fun

          Create JavaScript function

          Scope JS expressions

          Body

          function($parameters$){
            $END$
          }

          Parameters

          • parameters - no macro
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__JavaScript__fun__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__JavaScript__fun__after

          itar

          Iterate an array

          Scope JS statements

          Body

          for (var $INDEX$=0;$INDEX$<$ARRAY$.length;$INDEX$++){
          var $VAR$ = $ARRAY$[$INDEX$];$END$
          }

          Parameters

          • ARRAY - no macro
          • INDEX - Suggests non-used name which can be used for an index variable at the evaluation point.
          • VAR - When exectuted in variable declaration (where variable name should stand), suggests name for the variable.
          • END - The caret position after the template is applied.

          Before expansion
          Reference__Options__Templates__Live_Templates__Predefined__JavaScript__itar__before
          After expansion
          Reference__Options__Templates__Live_Templates__Predefined__JavaScript__itar__after

          Razor

          Template Details
          @inherits

          Razor inherits directive

          Scope Razor CSharp tags

          Body

          @inherits $TYPENAME$
          $END$

          Parameters

          • TYPENAME - Guess type expected at this point
          • END - The caret position after the template is applied.
          @model

          Razor model directive

          Scope Razor CSharp tags

          Body

          @model $TYPENAME$
          $END$

          Parameters

          • TYPENAME - Show type completion list at the point where the variable is evaluated
          • END - The caret position after the template is applied.
          @section

          Razor section

          Scope Razor CSharp tags

          Body

          @section $section$
          {
          $END$
          }

          Parameters

          • section - Show basic code completion list at the point where the variable is evaluated
          • END - The caret position after the template is applied.