Edit

Share via


TextWriter Constructors

Definition

Initializes a new instance of the TextWriter class.

Overloads

TextWriter()

Initializes a new instance of the TextWriter class.

TextWriter(IFormatProvider)

Initializes a new instance of the TextWriter class with the specified format provider.

TextWriter()

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

Initializes a new instance of the TextWriter class.

C#
protected TextWriter();

Remarks

Use this constructor overload when you do not want to provide a value for the FormatProvider property. When the FormatProvider property is null, the culture of the current thread is used for formatting.

Use this constructor for derived classes.

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

See also

Applies to

.NET 9 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
.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

TextWriter(IFormatProvider)

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

Initializes a new instance of the TextWriter class with the specified format provider.

C#
protected TextWriter(IFormatProvider formatProvider);
C#
protected TextWriter(IFormatProvider? formatProvider);

Parameters

formatProvider
IFormatProvider

An IFormatProvider object that controls formatting.

Remarks

Use this constructor overload to provide a value for the FormatProvider property. The value of the FormatProvider property specifies the culture-specific formatting that is used when you call the Write and WriteLine methods. If you do not want to provide a format provider, you create an instance by using the TextWriter() constructor, which sets the FormatProvider property to null. When the FormatProvider property is null, the culture of the current thread is used for formatting.

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

See also

Applies to

.NET 9 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
.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