Telerik® JustCode™ by Progress

Iteration Templates insert a code snippet related to C#/VB.NET/JavaScript iteration statements like foreach or for.

To insert a template

Press Alt+End. From the pop-up menu, select the template you want to insert.

Predefined Iteration Templates

for (int _ = 0; _ < _; _++) {}

Generates a general purpose for statement.

Language

C#

Default acronym

f

Parameters

  • Upper Condition Value - $1=SELECT_VARIABLE(int,uint)$ - instance of int/uint.
  • Loop Index Variable - $2=SUGGEST_INDEX_NAME()$ - name of the loop index variable.

Description

  • for (int $2=SUGGEST_INDEX_NAME()$ = 0; $2$ < $1=SELECT_VARIABLE(int,uint)$; $2$++)

    {

    |

    }

Example

Initial state

Code Template Iter for 3 before

Apply template

Code Template Iter for 3 after

Using the Tab key you can iterate over the valid int/uint variables (currently foo and bar) available in scope. In the example, bar is automatically suggested.

for (int _ = 0; _ < _.Length; _++) { _ _ = _[_]; }

Generates a for statement which iterates over an instance of array.

Language

C#

Default acronym

fl

Parameters

  • Array - $1=SELECT_VARIABLE([])$ - instance of array.
  • Loop Index Variable - $2=SUGGEST_INDEX_NAME()$ - name of the loop index variable.
  • Current Element Variable Type - $3=GET_ELEMENT_TYPE($1$)$ - type of the variable holding the current element.
  • Current Element Variable Name - $4=SUGGEST_ELEMENT_NAME($1$)$ - name of the variable holding the current element.

Description

  • for (int $2=SUGGEST_INDEX_NAME()$ = 0; $2$ < $1=SELECT_VARIABLE([])$.Length; $2$++)

    {

    $3=GET_ELEMENT_TYPE($1$)$ $4=SUGGEST_ELEMENT_NAME($1$)$ = $1$[$2$];

    |

    }

Example

Initial state

Code Template Iter for 2 before

Apply template

Code Template Iter for 2 after

Using the Tab key you can iterate over the valid arrays (currently foos and bars) available in scope. In the example, foos is automatically suggested as well as the type and the name of the variable holding the current element.

for (int _ = 0; _ < _.Count; _++) { _ _ = _[_]; }

Generates a for statement which iterates over an instance of System.Collections.ArrayList, System.Collections.IList, System.Collections.Generic.List, or System.Collections.Generic.IList.

Language

C#

Default acronym

fc

Parameters

  • ArrayList/Collection - $1=SELECT_VARIABLE(System.Collections.ArrayList,System.Collections.IList,System.Collections.Generic.List,System.Collections.Generic.IList)$ - instance of System.Collections.ArrayList, System.Collections.IList, System.Collections.Generic.List, or System.Collections.Generic.IList to iterate over.
  • Loop Index Variable - $2=SUGGEST_INDEX_NAME()$ - name of the loop index variable.
  • Current Element Variable Type - $3=GET_ELEMENT_TYPE($1$)$ - type of the variable holding the current element.
  • Current Element Variable Name - $4=SUGGEST_ELEMENT_NAME($1$)$ - name of the variable holding the current element.

Description

  • for (int $2=SUGGEST_INDEX_NAME()$ = 0; $2$ < $1=SELECT_VARIABLE(System.Collections.ArrayList,System.Collections.IList,System.Collections.Generic.List,System.Collections.Generic.IList)$.Count; $2$++)

    {

    $3=GET_ELEMENT_TYPE($1$)$ $4=SUGGEST_ELEMENT_NAME($1$)$ = $1$[$2$];

    |

    }

Example

Initial state

Code Template Iter for 1 before

Apply template

Code Template Iter for 1 after

Using the Tab key you can iterate over the valid arrays/collections (currently foos and bars) available in scope. In the example, bars is automatically suggested as well as the type and the name of the variable holding the current element.

while (_) { }

Generates a general purpose while statement.

Language

C#

Default acronym

w

Parameters

  • Variable - $1=SELECT_VARIABLE(bool)$ - instance of bool.

Description

  • while ($1=SELECT_VARIABLE(bool)$)

    {

    |

    }

Example

Initial state

Code Template Iter while 1 before

Apply template

Code Template Iter while 1 after

Using the Tab key you can iterate over the valid bool variables (currently foo and bar) available in scope. In the example, bar is automatically suggested.

do { } while (_)

Generates a general purpose do-while statement.

Language

C#

Default acronym

dlw

Parameters

  • Variable - $1=SELECT_VARIABLE(bool)$ - instance of bool.

Description

  • do

    {

    |

    }while ($1=SELECT_VARIABLE(bool)$);

Example

Initial state

Code Template Iter while 1 before

Apply template

Code Template Iter Do While After

Using the Tab key you can iterate over the valid bool variables (currently foo and bar) available in scope. In the example, bar is automatically suggested.

foreach (_ _ in _) { }

Generates a foreach statement which iterates over an instance of array, System.Collections.ArrayList, System.Collections.IList, System.Collections.Generic.List, or System.Collections.Generic.IList.

Language

C#

Default acronym

fe

Parameters

  • Array/Collection - $1=SELECT_VARIABLE([],System.Collections.ArrayList,System.Collections.IList,System.Collections.IDictionary,System.Collections.Generic.List,System.Collections.Generic.IList,System.Collections.Generic.IDictionary,System.Collections.IEnumerable,System.Collections.Generic.IEnumerable)$ - instance of array, System.Collections.ArrayList, System.Collections.IList, System.Collections.Generic.List, or System.Collections.Generic.IList to iterate over.
  • Type - $3=GET_ELEMENT_TYPE($1$)$ - type of the iterator variable.
  • Variable - $2=SUGGEST_ELEMENT_NAME($1$)$ - name of the iterator variable.

Description

  • foreach ($3=GET_ELEMENT_TYPE($1$)$ $2=SUGGEST_ELEMENT_NAME($1$)$ in $1=SELECT_VARIABLE([],System.Collections.ArrayList,System.Collections.IList,System.Collections.IDictionary,System.Collections.Generic.List,System.Collections.Generic.IList,System.Collections.Generic.IDictionary,System.Collections.IEnumerable,System.Collections.Generic.IEnumerable)$)

    {

    |

    }

Example

Initial state

Code Template Iter for 1 before

Apply template

Code Template Iter foreach 1 after

Using the Tab key you can iterate over the valid arrays/collections (currently foos and bars) available in scope. In the example, bars is automatically suggested as well as the type and the name of the iterator variable.

See Also