StreamWriter.WriteLine Method

Definition

Overloads

WriteLine(String, Object, Object, Object)

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

WriteLine(String, Object, Object)

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

WriteLine(String, ReadOnlySpan<Object>)

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

WriteLine(String)

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

WriteLine(String, Object)

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

WriteLine(ReadOnlySpan<Char>)

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

WriteLine(String, Object[])

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

WriteLine(String, Object, Object, Object)

Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs

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

C#
public override 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.

Remarks

See WriteLine(String, Object, Object, Object) for a description of the composite formatting capabilities offered.

Applies to

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

WriteLine(String, Object, Object)

Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs

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

C#
public override 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.

Remarks

See WriteLine(String, Object, Object) for a description of the composite formatting capabilities offered.

Applies to

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

WriteLine(String, ReadOnlySpan<Object>)

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

C#
public override 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)

Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs

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

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

Parameters

value
String

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

Remarks

This overload is equivalent to the TextWriter.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.

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

WriteLine(String, Object)

Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs

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

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

Parameters

format
String

A composite format string.

arg0
Object

The object to format and write.

Remarks

See WriteLine(String, Object) for a description of the composite formatting capabilities offered.

Applies to

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

WriteLine(ReadOnlySpan<Char>)

Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs

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

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

Parameters

buffer
ReadOnlySpan<Char>

The character span to write to the 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

WriteLine(String, Object[])

Source:
StreamWriter.cs
Source:
StreamWriter.cs
Source:
StreamWriter.cs

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

C#
public override 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.

Remarks

See WriteLine(String, Object[]) for a description of the composite formatting capabilities offered.

Applies to

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