TextTransformation.WriteLine Method (String, [])

Appends a formatted string, which contains zero or more format specifications, and the default line terminator, to the generated text output. Each format specification is replaced by the string representation of a corresponding object argument.

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

Syntax

'宣言
Public Sub WriteLine ( _
    format As String, _
    ParamArray args As Object() _
)
'使用
Dim instance As TextTransformation
Dim format As String
Dim args As Object()

instance.WriteLine(format, args)
public void WriteLine(
    string format,
    params Object[] args
)
public:
void WriteLine(
    String^ format, 
    ... array<Object^>^ args
)
public function WriteLine(
    format : String, 
    ... args : Object[]
)

Parameters

  • format
    Type: System.String

    A string that contains zero or more format specifications.

  • args
    Type: []

    An array of objects to format.

Exceptions

Exception Condition
ArgumentNullException

format is a null reference (Nothing in Visual Basic).

-or-

args is a null reference (Nothing in Visual Basic).

FormatException

format is invalid.

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 message = @"{0}: This is text to append number {1:F}.";

    Write(message, 0, 0);          //Using the Write method
    WriteLine(null);               //Using the WriteLine method
    WriteLine(null);               //Using the WriteLine method
    
    for(int j=1; j<4; j++)
    {
        WriteLine(message, j, j);  //Using the WriteLine method
    }
#>
<#
    Dim message as String = "{0}: This is text to append number {1:F}."
    Dim j as Integer = 0

    Write(message, 0, 0)          'Using the Write method
    WriteLine(Nothing)            'Using the WriteLine method
    WriteLine(Nothing)            'Using the WriteLine method
    
    For j = 1 To 3

        WriteLine(message, j, j)  'Using the WriteLine method
    Next
#>

This example produces the following output:

0: This is text to append number 0.00.

    

1: This is text to append number 1.00.

2: This is text to append number 2.00.

3: This is text to append number 3.00.

Permissions

See Also

Concepts

Formatting Overview

Numeric Format Strings

Date and Time Format Strings

Enumeration Format Strings

How to: Append Text to the Generated Text

Reference

TextTransformation Class

TextTransformation Members

WriteLine Overload

Microsoft.VisualStudio.TextTemplating Namespace

GenerationEnvironment

StringBuilder

AppendFormat

MaxCapacity

ArgumentOutOfRangeException

FormatException

ArgumentNullException