TextTransformation.Write Method (String)

 

Appends a copy of the specified string to the generated text output.

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

public void Write(
	string textToAppend
)

Parameters

textToAppend
Type: System.String

The string to append.

Exception Condition
ArgumentOutOfRangeException

Enlarging the value of the underlying StringBuilder would exceed MaxCapacity.

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

The following code example demonstrates calling the Write 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
    }
#>

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.

Return to top
Show: