TextTransformation.WriteLine Method (String)

Appends a copy of the specified string and the default line terminator to the generated text output.

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating (in Microsoft.VisualStudio.TextTemplating.dll)

Syntax

'宣言
Public Sub WriteLine ( _
    textToAppend As String _
)
'使用
Dim instance As TextTransformation
Dim textToAppend As String

instance.WriteLine(textToAppend)
public void WriteLine(
    string textToAppend
)
public:
void WriteLine(
    String^ textToAppend
)
public function WriteLine(
    textToAppend : String
)

Parameters

Exceptions

Exception Condition
ArgumentOutOfRangeException

Enlarging the value of the underlying StringBuilder would exceed MaxCapacity.

Remarks

The WriteLine method can be used directly in a text template.

Examples

The following code example demonstrates calling the WriteLine method from a text template. Paste this code into any text template file and run the text template transformation to see the results.

<#  
    string text = @"This is text to append to my output file.";

    Write(text);          //Using the Write method
    WriteLine(null);      //Using the WriteLine method  
    WriteLine(null);      //Using the WriteLine method  
    
    for(int i=1; i<4; i++)
    {
        WriteLine(text);  //Using the WriteLine method  
    }
#>
<#  
    Dim text as String = "This is text to append to my output file."
    Dim i as Integer = 0

    Write(text)            'Using the Write method
    WriteLine(Nothing)     'Using the WriteLine method  
    WriteLine(Nothing)     'Using the WriteLine method  
    
    For i = 1 To 3

        WriteLine(text)    'Using the WriteLine method  
    Next
#>

This example produces the following output:

This is text to append to my output file.

    

This is text to append to my output file.

This is text to append to my output file.

This is text to append to my output file.

Permissions

See Also

Concepts

How to: Append Text to the Generated Text

Reference

TextTransformation Class

TextTransformation Members

WriteLine Overload

Microsoft.VisualStudio.TextTemplating Namespace

GenerationEnvironment

StringBuilder

MaxCapacity

ArgumentOutOfRangeException