共用方式為


TextTransformation.Write 方法 (String)

將所指定字串的複本附加至產生的文字輸出。

命名空間:  Microsoft.VisualStudio.TextTemplating
組件:  Microsoft.VisualStudio.TextTemplating.11.0 (在 Microsoft.VisualStudio.TextTemplating.11.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 to the Generated Text