Partager via


TextTransformation.WriteLine, méthode (String)

Ajoute, à la sortie de texte générée, une copie de la chaîne spécifiée et la marque de fin de ligne par défaut.

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

Syntaxe

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

Paramètres

  • textToAppend
    Type : String

    Chaîne à écrire.

Exceptions

Exception Condition
ArgumentOutOfRangeException

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

Notes

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

Exemples

L'exemple de code suivant montre l'appel de la méthode WriteLine à 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

WriteLine, surcharge

Microsoft.VisualStudio.TextTemplating, espace de noms

GenerationEnvironment

StringBuilder

MaxCapacity

ArgumentOutOfRangeException

Autres ressources

How to: Append to the Generated Text