Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Studio SDK
 Expression 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
Expression Syntax (Domain-Specific Languages)

Updated: July 2008

You can use expression blocks in text templates to add strings to the generated text output. Expression blocks contain code that is first added to the generated transformation class with calls to ToString() attached to them. The transformation process will also apply the template's culture to the generated string. Typically, expression blocks are embedded inside text blocks. They are designed to change some aspect of the generated output text to use calculated values from external data, such as model files.

In text templates, expression blocks are delineated by using opening (<#=) and closing (#>) text template tags. The general syntax is:

<#= ExpressionCode #>

Note:

Expressions must be on a single line in Visual Basic templates. Expressions can be on multiple lines in Visual C# templates.

The following code sample shows an expression:

<#= operation.Name #>

The following code sample shows a statement that performs a calculation, and then shows an expression that adds the result as a string to the generated text output:

C#
<#
    int result = 95 * 95;
#> 
<#= result #>

The result of the previous example in the generated text is:

9025

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