Udostępnij za pośrednictwem


Metoda TextTransformation.Write — (String)

Dołącza kopię określonego ciągu znaków tekstowych wygenerowanych danych wyjściowych.

Przestrzeń nazw:  Microsoft.VisualStudio.TextTemplating
Zestaw:  Microsoft.VisualStudio.TextTemplating.11.0 (w Microsoft.VisualStudio.TextTemplating.11.0.dll)

Składnia

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

Parametry

Wyjątki

Wyjątek Warunek
ArgumentOutOfRangeException

Powiększanie wartości instrumentu bazowego StringBuilder przekroczyłaby MaxCapacity.

Uwagi

Write Metoda może być używana bezpośrednio w szablonie tekstu.

Przykłady

Poniższy przykład kodu pokazuje wywołania Write metody z szablonu tekstu.Wklej ten kod do dowolnego pliku tekstowego, szablon, a następnie uruchom transformacji tekst szablonu, aby zobaczyć wyniki.

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

Ten przykład generuje następujące wyniki:

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.

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

TextTransformation Klasa

Przeciążenie Write

Przestrzeń nazw Microsoft.VisualStudio.TextTemplating

GenerationEnvironment

StringBuilder

MaxCapacity

ArgumentOutOfRangeException

Inne zasoby

How to: Append to the Generated Text