Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Método TextWriter.WriteLine (String, Object, Object)

 

Grava uma cadeia de caracteres formatada e uma nova linha na cadeia de texto ou no fluxo, usando a mesma semântica que o método String.Format(String, Object, Object).

Namespace:   System.IO
Assembly:  mscorlib (em mscorlib.dll)

public virtual void WriteLine(
	string format,
	object arg0,
	object arg1
)

Parâmetros

format
Type: System.String

Uma cadeia de caracteres de formato composto (consulte Comentários).

arg0
Type: System.Object

O primeiro objeto a ser formatado e gravado.

arg1
Type: System.Object

O segundo objeto a ser formatado e gravado.

Exception Condition
ArgumentNullException

format é null.

ObjectDisposedException

O TextWriter está fechado.

IOException

Ocorre um erro de E/S.

FormatException

format não é uma cadeia de caracteres de formato de composição válida.

- ou -

O índice de um item de formato é menor que 0 (zero) ou maior ou igual ao número de objetos a serem formatados (que, para essa sobrecarga de método, é dois).

This method uses the of the .NET Framework to convert the value of an object to its string representation and to embed that representation in a string. The .NET Framework provides extensive formatting support, which is described in greater detail in the following formatting topics:

  • For more information about the composite formatting feature, see Composite Formatting.

  • For more information about numeric format specifiers, see Standard Numeric Format Strings and Custom Numeric Format Strings.

  • For more information about date and time format specifiers, see Standard DateTime Format Strings and Custom DateTime Format Strings.

  • For more information about enumeration format specifiers, see Enumeration Format Strings.

  • For more information about formatting, see Formatting Types.

The format parameter consists of zero or more runs of text intermixed with zero or more indexed placeholders, called format items, that correspond to an object in the parameter list of this method. The formatting process replaces each format item with the string representation of the value of the corresponding object.

The syntax of a format item is as follows:

{index[,length][:formatString]}

Elements in square brackets are optional. The following table describes each element. For more information about the composite formatting feature, including the syntax of a format item, see Composite Formatting.

Element

Description

index

The zero-based position in the parameter list of the object to be formatted. If the object specified by index is null, the format item is replaced by F:System.String.Empty. Because this overload has two objects in its parameter list, the value of index must always be 0 or 1. If there is no parameter in the index position, a T:System.FormatException is thrown.

,length

The minimum number of characters in the string representation of the parameter. If positive, the parameter is right-aligned; if negative, it is left-aligned.

:formatString

A standard or custom format string that is supported by the object to be formatted. Possible values for formatString are the same as the values supported by the object's ToString(format) method. If formatString is not specified and the object to be formatted implements the T:System.IFormattable interface, null is passed as the value of the format parameter that is used as the M:System.IFormattable.ToString(System.String,System.IFormatProvider) format string.

The leading and trailing brace characters, "{" and "}", are required. To specify a single literal brace character in format, specify two leading or trailing brace characters; that is, "{{" or "}}".

This method does not search the specified string for individual newline characters (hexadecimal 0x000a) and replace them with P:System.IO.TextWriter.NewLine.

If a specified object is not referenced in the format string, it is ignored.

The line terminator is defined by the F:System.IO.TextWriter.CoreNewLine field.

For a list of common I/O tasks, see Common I/O Tasks.

Plataforma Universal do Windows
Disponível desde 10
.NET Framework
Disponível desde 1.1
Silverlight
Disponível desde 2.0
Windows Phone Silverlight
Disponível desde 7.0
Retornar ao início
Mostrar: