TextTransformation.WriteLine 方法 (String)

将指定的字符串副本和默认的行终止符追加到生成的文本输出。

命名空间:  Microsoft.VisualStudio.TextTemplating
程序集:  Microsoft.VisualStudio.TextTemplating.10.0(在 Microsoft.VisualStudio.TextTemplating.10.0.dll 中)

语法

声明
Public Sub WriteLine ( _
    textToAppend As String _
)
public void WriteLine(
    string textToAppend
)
public:
void WriteLine(
    String^ textToAppend
)
member WriteLine : 
        textToAppend:string -> unit 
public function WriteLine(
    textToAppend : String
)

参数

异常

异常 条件
ArgumentOutOfRangeException

增大基础 StringBuilder 的值,该值将超过 MaxCapacity

备注

WriteLine 方法可直接用于文本模板中。

示例

下面的代码示例演示从文本模板调用 WriteLine 方法。 将此代码粘贴到任何文本模板文件中并运行文本模板转换以查看结果。

<#  
    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 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.

.NET Framework 安全性

请参见

参考

TextTransformation 类

WriteLine 重载

Microsoft.VisualStudio.TextTemplating 命名空间

GenerationEnvironment

StringBuilder

MaxCapacity

ArgumentOutOfRangeException

其他资源

How to: Append Text to the Generated Text