Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Studio SDK
 Statement Syntax

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Domain-Specific Language Tools
Statement Syntax

Updated: July 2008

You can use statement blocks in text templates to control the flow of processing in the text template. Statement blocks enable you either to structure templates to output things conditionally or to iterate over data to output things repeatedly for each item in that data.

Code statements are delineated using opening (<#) and closing (#>) text template tags. The general syntax is as follows.

<# StatementCode #>

You should use the language declared in the language parameter of the template directive to write the code statements. The code statement must compile successfully.

Note:

C# is the default text template language. For more information, see How to: Specify a Language in Text Templates.

The following example shows a C# code statement in a text template.

<# WriteLine("Hello"); #>

The following example shows a code statement on more than one line in a text template.

<#
    for(int i=0; i<4; i++)
    {
        WriteLine("Hello");
    }
#>

The following example shows an alternate version of the same statements.

<#
    for(int i=0; i<4; i++)
    {
#> 
<#
        WriteLine("Hello");
#>        
<#
    }
#>

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker