Método TextTransformation.WriteLine (String, array<Object )

Acrescenta uma seqüência de caracteres formatada, contém zero ou mais especificações de formato e o terminador de linha padrão, a saída de texto gerado. Cada especificação de formato é substituída pela representação de seqüência de caracteres de um argumento de objeto correspondente.

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

Sintaxe

'Declaração
Public Sub WriteLine ( _
    format As String, _
    ParamArray args As Object() _
)
public void WriteLine(
    string format,
    params Object[] args
)
public:
void WriteLine(
    String^ format, 
    ... array<Object^>^ args
)
member WriteLine : 
        format:string * 
        args:Object[] -> unit 
public function WriteLine(
    format : String, 
    ... args : Object[]
)

Parâmetros

  • format
    Tipo: System.String
    Uma seqüência de caracteres que contém zero ou mais especificações de formato.
  • args
    Tipo: array<System.Object[]
    Uma matriz de objetos a serem formatados.

Exceções

Exceção Condição
ArgumentNullException

format é nulluma referência nula (Nothing no Visual Basic).

- ou -

args é nulluma referência nula (Nothing no Visual Basic).

FormatException

format é inválido.

ArgumentOutOfRangeException

Aumentando o valor de base StringBuilder excederia MaxCapacity.

Comentários

O WriteLine método pode ser usado diretamente em um modelo de texto.

Exemplos

O exemplo de código a seguir demonstra a chamada a WriteLine método a partir de um modelo de texto. Cole este código no arquivo de modelo de texto e executar a transformação do modelo de texto para ver os resultados.

<#
    string message = @"{0}: This is text to append number {1:F}.";

    Write(message, 0, 0);          //Using the Write method
    WriteLine(null);               //Using the WriteLine method
    WriteLine(null);               //Using the WriteLine method
    
    for(int j=1; j<4; j++)
    {
        WriteLine(message, j, j);  //Using the WriteLine method
    }
#>
<#
    Dim message as String = "{0}: This is text to append number {1:F}."
    Dim j as Integer = 0

    Write(message, 0, 0)          'Using the Write method
    WriteLine(Nothing)            'Using the WriteLine method
    WriteLine(Nothing)            'Using the WriteLine method
    
    For j = 1 To 3

        WriteLine(message, j, j)  'Using the WriteLine method
    Next
#>

Esse exemplo produz a seguinte saída.

0: This is text to append number 0.00.

    

1: This is text to append number 1.00.

2: This is text to append number 2.00.

3: This is text to append number 3.00.

Segurança do .NET Framework

Consulte também

Referência

TextTransformation Classe

Sobrecargas WriteLine

Namespace Microsoft.VisualStudio.TextTemplating

GenerationEnvironment

StringBuilder

AppendFormat

MaxCapacity

ArgumentOutOfRangeException

FormatException

ArgumentNullException

Outros recursos

Tipos de Formatação

Numeric Format Strings

Date and Time Format Strings

Sequências de Caracteres de Formatação de Enumeração

How to: Append Text to the Generated Text