WriteLine Method (String, Object, Object, Object)

TextWriter.WriteLine Method (String, Object, Object, Object)


Writes out a formatted string and a new line, using the same semantics as Format.

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

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


Type: System.String

A composite format string (see Remarks).

Type: System.Object

The first object to format and write.

Type: System.Object

The second object to format and write.

Type: System.Object

The third object to format and write.

Exception Condition

format is null.


The TextWriter is closed.


An I/O error occurs.


format is not a valid composite format string.


The index of a format item is less than 0 (zero), or greater than or equal to the number of objects to be formatted (which, for this method overload, is three).

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:

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:


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.




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 String.Empty. Because this overload has three objects in its parameter list, the value of index must always be 0, 1, or 2. If there is no parameter in the index position, a FormatException is thrown.


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.


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 IFormattable interface, null is passed as the value of the format parameter that is used as the IFormattable.ToString 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 NewLine.

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

The line terminator is defined by the CoreNewLine field.

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

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft