Freigeben über


TextTransformation.Write-Methode (String)

Fügt eine Kopie der angegebenen Zeichenfolge an die generierte Textausgabe an.

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

Syntax

'Declaration
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
)

Parameter

Ausnahmen

Ausnahme Bedingung
ArgumentOutOfRangeException

Wenn derWer des zugrunde liegenden StringBuilder-Elements vergrößert würde, würde MaxCapacity überschritten.

Hinweise

Die Write-Methode kann direkt in einer Textvorlage verwendet werden.

Beispiele

Im folgenden Codebeispiel wird das Aufrufen der Write-Methode in einer Textvorlage dargestellt. Fügen Sie diesen Code in eine beliebige Textvorlagendatei ein, und führen Sie die Textvorlagentransformation aus, um die Ergebnisse zu sehen.

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

Dieses Beispiel erzeugt folgende Ausgabe:

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-Sicherheit

Siehe auch

Referenz

TextTransformation Klasse

Write-Überladung

Microsoft.VisualStudio.TextTemplating-Namespace

GenerationEnvironment

StringBuilder

MaxCapacity

ArgumentOutOfRangeException

Weitere Ressourcen

How to: Append Text to the Generated Text