Partager via


TextTransformation.Write, méthode (String)

Ajoute une copie de la chaîne spécifiée à la sortie de texte générée.

Espace de noms :  Microsoft.VisualStudio.TextTemplating
Assembly :  Microsoft.VisualStudio.TextTemplating.11.0 (dans Microsoft.VisualStudio.TextTemplating.11.0.dll)

Syntaxe

'Déclaration
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
)

Paramètres

Exceptions

Exception Condition
ArgumentOutOfRangeException

Une augmentation de la valeur du StringBuilder sous-jacent dépasserait MaxCapacity.

Notes

La méthode Write peut être utilisée directement dans un modèle de texte.

Exemples

L'exemple de code suivant montre l'appel de la méthode Write à partir d'un modèle de texte.Collez ce code dans un fichier de modèle de texte et exécutez la transformation du modèle de texte pour consulter les résultats.

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

Cet exemple produit la sortie suivante :

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.

Sécurité .NET Framework

Voir aussi

Référence

TextTransformation Classe

Write, surcharge

Microsoft.VisualStudio.TextTemplating, espace de noms

GenerationEnvironment

StringBuilder

MaxCapacity

ArgumentOutOfRangeException

Autres ressources

How to: Append to the Generated Text