TextTransformation.Write 方法 (String)

向生成的文本输出追加指定字符串的副本。

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

语法

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

参数

异常

异常 条件
ArgumentOutOfRangeException

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

备注

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

示例

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

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

Write 重载

Microsoft.VisualStudio.TextTemplating 命名空间

GenerationEnvironment

StringBuilder

MaxCapacity

ArgumentOutOfRangeException

其他资源

How to: Append Text to the Generated Text