次の方法で共有


TextTransformation.WriteLine メソッド (String)

指定した文字列のコピーと既定の行終端記号を、生成されたテキスト出力の末尾に追加します。

名前空間:  Microsoft.VisualStudio.TextTemplating
アセンブリ:  Microsoft.VisualStudio.TextTemplating.11.0 (Microsoft.VisualStudio.TextTemplating.11.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 to the Generated Text