TextWriter.WriteLine Method

Definition

Writes data to the text stream, followed by a line terminator.

Overloads

WriteLine(String, Object, Object)

Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object, Object) method.

WriteLine(Char[], Int32, Int32)

Writes a subarray of characters to the text stream, followed by a line terminator.

WriteLine(String, ReadOnlySpan<Object>)

Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, ReadOnlySpan<Object>).

WriteLine(String, Object[])

Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object).

WriteLine(String, Object)

Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object) method.

WriteLine(UInt64)

Writes the text representation of an 8-byte unsigned integer to the text stream, followed by a line terminator.

WriteLine(String, Object, Object, Object)

Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object).

WriteLine(UInt32)

Writes the text representation of a 4-byte unsigned integer to the text stream, followed by a line terminator.

WriteLine(StringBuilder)

Writes the text representation of a string builder to the text stream, followed by a line terminator.

WriteLine(String)

Writes a string to the text stream, followed by a line terminator.

WriteLine(Single)

Writes the text representation of a 4-byte floating-point value to the text stream, followed by a line terminator.

WriteLine(Double)

Writes the text representation of a 8-byte floating-point value to the text stream, followed by a line terminator.

WriteLine(Object)

Writes the text representation of an object to the text stream, by calling the ToString method on that object, followed by a line terminator.

WriteLine(Int64)

Writes the text representation of an 8-byte signed integer to the text stream, followed by a line terminator.

WriteLine(Int32)

Writes the text representation of a 4-byte signed integer to the text stream, followed by a line terminator.

WriteLine(Decimal)

Writes the text representation of a decimal value to the text stream, followed by a line terminator.

WriteLine(Char[])

Writes an array of characters to the text stream, followed by a line terminator.

WriteLine(Char)

Writes a character to the text stream, followed by a line terminator.

WriteLine(Boolean)

Writes the text representation of a Boolean value to the text stream, followed by a line terminator.

WriteLine()

Writes a line terminator to the text stream.

WriteLine(ReadOnlySpan<Char>)

Writes the text representation of a character span to the text stream, followed by a line terminator.

WriteLine(String, Object, Object)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object, Object) method.

C#
public virtual void WriteLine(string format, object arg0, object arg1);
C#
public virtual void WriteLine(string format, object? arg0, object? arg1);

Parameters

format
String

A composite format string.

arg0
Object

The first object to format and write.

arg1
Object

The second object to format and write.

Exceptions

format is null.

An I/O error occurs.

format is not a valid composite format string.

-or-

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 two).

Remarks

This method uses composite formatting to convert the value of an object to its string representation and to embed that representation in a string. .NET 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:

{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 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 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(string 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.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Char[], Int32, Int32)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes a subarray of characters to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(char[] buffer, int index, int count);

Parameters

buffer
Char[]

The character array from which data is read.

index
Int32

The character position in buffer at which to start reading data.

count
Int32

The maximum number of characters to write.

Exceptions

The buffer length minus index is less than count.

The buffer parameter is null.

index or count is negative.

An I/O error occurs.

Remarks

This method will write count characters of data into this TextWriter from the buffer character array starting at position index.

This overload is equivalent to calling the Write(Char[]) method followed by WriteLine for each character in buffer between index and (index + count).

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(String, ReadOnlySpan<Object>)

Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, ReadOnlySpan<Object>).

C#
public virtual void WriteLine(string format, scoped ReadOnlySpan<object?> arg);

Parameters

format
String

A composite format string.

arg
ReadOnlySpan<Object>

An object span that contains zero or more objects to format and write.

Applies to

.NET 10 and .NET 9
Product Versions
.NET 9, 10

WriteLine(String, Object[])

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object).

C#
public virtual void WriteLine(string format, params object[] arg);
C#
public virtual void WriteLine(string format, params object?[] arg);

Parameters

format
String

A composite format string.

arg
Object[]

An object array that contains zero or more objects to format and write.

Exceptions

A string or object is passed in as null.

An I/O error occurs.

format is not a valid composite format string.

-or-

The index of a format item is less than 0 (zero), or greater than or equal to the length of the arg array.

Remarks

This method uses composite formatting to convert the value of an object to its string representation and to embed that representation in a string. .NET 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:

{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 String.Empty. Because this overload has an array in its parameter list, the value of index must always be less than the length of the array. If there is no parameter in the index position, a 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(string 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.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(String, Object)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes a formatted string and a new line to the text stream, using the same semantics as the Format(String, Object) method.

C#
public virtual void WriteLine(string format, object arg0);
C#
public virtual void WriteLine(string format, object? arg0);

Parameters

format
String

A composite format string.

arg0
Object

The object to format and write.

Exceptions

format is null.

An I/O error occurs.

format is not a valid composite format string.

-or-

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 one).

Remarks

This method uses composite formatting to convert the value of an object to its string representation and to embed that representation in a string. .NET 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:

{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 String.Empty. Because this overload has only a single object in its parameter list, the value of index must always be 0. If there is no parameter in the index position, a 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(string 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.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(UInt64)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Important

This API is not CLS-compliant.

Writes the text representation of an 8-byte unsigned integer to the text stream, followed by a line terminator.

C#
[System.CLSCompliant(false)]
public virtual void WriteLine(ulong value);

Parameters

value
UInt64

The 8-byte unsigned integer to write.

Attributes

Exceptions

An I/O error occurs.

Remarks

The text representation of the specified value is produced by calling the UInt64.ToString method. The FormatProvider property, if not null, specifies the culture-specific formatting.

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(String, Object, Object, Object)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes out a formatted string and a new line to the text stream, using the same semantics as Format(String, Object).

C#
public virtual void WriteLine(string format, object arg0, object arg1, object arg2);
C#
public virtual void WriteLine(string format, object? arg0, object? arg1, object? arg2);

Parameters

format
String

A composite format string.

arg0
Object

The first object to format and write.

arg1
Object

The second object to format and write.

arg2
Object

The third object to format and write.

Exceptions

format is null.

An I/O error occurs.

format is not a valid composite format string.

-or-

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).

Remarks

This method uses composite formatting to convert the value of an object to its string representation and to embed that representation in a string. .NET 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:

{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 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.
,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(string 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.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(UInt32)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Important

This API is not CLS-compliant.

Writes the text representation of a 4-byte unsigned integer to the text stream, followed by a line terminator.

C#
[System.CLSCompliant(false)]
public virtual void WriteLine(uint value);

Parameters

value
UInt32

The 4-byte unsigned integer to write.

Attributes

Exceptions

An I/O error occurs.

Remarks

The text representation of the specified value is produced by calling the UInt32.ToString method. The FormatProvider property, if not null, specifies the culture-specific formatting.

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(StringBuilder)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of a string builder to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(System.Text.StringBuilder? value);

Parameters

value
StringBuilder

The string, as a string builder, to write to the text stream.

Remarks

The text representation of the specified value is produced by calling the StringBuilder.ToString method.

The line terminator is defined by the CoreNewLine field.

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10

WriteLine(String)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes a string to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(string value);
C#
public virtual void WriteLine(string? value);

Parameters

value
String

The string to write. If value is null, only the line terminator is written.

Exceptions

An I/O error occurs.

Remarks

This overload is equivalent to the Write(Char[]) overload.

The line terminator is defined by the CoreNewLine field.

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

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Single)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of a 4-byte floating-point value to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(float value);

Parameters

value
Single

The 4-byte floating-point value to write.

Exceptions

An I/O error occurs.

Remarks

The FormatProvider property, if not null, specifies the culture-specific formatting. For a list of common I/O tasks, see Common I/O Tasks.

The line terminator is defined by the CoreNewLine field.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Double)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of a 8-byte floating-point value to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(double value);

Parameters

value
Double

The 8-byte floating-point value to write.

Exceptions

An I/O error occurs.

Remarks

The FormatProvider property, if not null, specifies the culture-specific formatting. For a list of common I/O tasks, see Common I/O Tasks.

The line terminator is defined by the CoreNewLine field.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Object)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of an object to the text stream, by calling the ToString method on that object, followed by a line terminator.

C#
public virtual void WriteLine(object value);
C#
public virtual void WriteLine(object? value);

Parameters

value
Object

The object to write. If value is null, only the line terminator is written.

Exceptions

An I/O error occurs.

Remarks

This overload is equivalent to the Write(String, Object) overload. The FormatProvider property, if not null, specifies the culture-specific formatting.

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Int64)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of an 8-byte signed integer to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(long value);

Parameters

value
Int64

The 8-byte signed integer to write.

Exceptions

An I/O error occurs.

Remarks

The text representation of the specified value is produced by calling the Int64.ToString method. The TextWriter.FormatProvider property, if not null, specifies the culture-specific formatting.

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Int32)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of a 4-byte signed integer to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(int value);

Parameters

value
Int32

The 4-byte signed integer to write.

Exceptions

An I/O error occurs.

Remarks

The text representation of the specified value is produced by calling the Int32.ToString method. The TextWriter.FormatProvider property, if not null, specifies the culture-specific formatting.

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Decimal)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of a decimal value to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(decimal value);

Parameters

value
Decimal

The decimal value to write.

Exceptions

An I/O error occurs.

Remarks

The FormatProvider property, if not null, specifies the culture-specific formatting. For a list of common I/O tasks, see Common I/O Tasks.

The line terminator is defined by the CoreNewLine field.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Char[])

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes an array of characters to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(char[] buffer);
C#
public virtual void WriteLine(char[]? buffer);

Parameters

buffer
Char[]

The character array from which data is read.

Exceptions

An I/O error occurs.

Remarks

All the characters in buffer are written to the underlying stream. If the character array is null, only the line terminator is written.

This overload is equivalent to Write(Char[]) followed by WriteLine() .

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Char)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes a character to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(char value);

Parameters

value
Char

The character to write to the text stream.

Exceptions

An I/O error occurs.

Remarks

This overload is equivalent to Write(Char) followed by WriteLine() .

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(Boolean)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of a Boolean value to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(bool value);

Parameters

value
Boolean

The Boolean value to write.

Exceptions

An I/O error occurs.

Remarks

The text representation of the specified value is produced by calling the Boolean.ToString method.

This method outputs either Boolean.TrueString or Boolean.FalseString.

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine()

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes a line terminator to the text stream.

C#
public virtual void WriteLine();

Exceptions

An I/O error occurs.

Remarks

The line terminator is defined by the CoreNewLine field.

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

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

WriteLine(ReadOnlySpan<Char>)

Source:
TextWriter.cs
Source:
TextWriter.cs
Source:
TextWriter.cs

Writes the text representation of a character span to the text stream, followed by a line terminator.

C#
public virtual void WriteLine(ReadOnlySpan<char> buffer);

Parameters

buffer
ReadOnlySpan<Char>

The char span value to write to the text stream.

Remarks

The text representation of the specified value is produced by calling the ReadOnlySpan<Char>.ToString method.

The line terminator is defined by the CoreNewLine field.

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1