System.IO.TextWriter Class

public abstract class TextWriter : MarshalByRefObject, IDisposable

Base Types

Object
  MarshalByRefObject
    TextWriter

This type implements IDisposable.

Assembly

mscorlib

Library

BCL

Summary

Represents a writer that can write a sequential series of characters.

Description

TextWriter is designed for character output, whereas the Stream class is designed for byte input and output.

[Note: By default, a TextWriter is not thread safe. See System.IO.TextWriter.Synchronized(System.IO.TextWriter) for a thread-safe wrapper. ]

See Also

System.IO Namespace

Members

TextWriter Constructors

TextWriter(System.IFormatProvider) Constructor
TextWriter() Constructor

TextWriter Methods

TextWriter.Close Method
TextWriter.Dispose Method
TextWriter.Flush Method
TextWriter.Synchronized Method
TextWriter.System.IDisposable.Dispose Method
TextWriter.Write(System.String, System.Object[]) Method
TextWriter.Write(System.String, System.Object, System.Object, System.Object) Method
TextWriter.Write(System.String, System.Object, System.Object) Method
TextWriter.Write(System.String, System.Object) Method
TextWriter.Write(System.Object) Method
TextWriter.Write(System.String) Method
TextWriter.Write(System.Decimal) Method
TextWriter.Write(double) Method
TextWriter.Write(float) Method
TextWriter.Write(ulong) Method
TextWriter.Write(long) Method
TextWriter.Write(uint) Method
TextWriter.Write(int) Method
TextWriter.Write(bool) Method
TextWriter.Write(char[], int, int) Method
TextWriter.Write(char[]) Method
TextWriter.Write(char) Method
TextWriter.WriteLine(System.Decimal) Method
TextWriter.WriteLine(long) Method
TextWriter.WriteLine(uint) Method
TextWriter.WriteLine(int) Method
TextWriter.WriteLine(bool) Method
TextWriter.WriteLine(char[], int, int) Method
TextWriter.WriteLine(char[]) Method
TextWriter.WriteLine(char) Method
TextWriter.WriteLine() Method
TextWriter.WriteLine(ulong) Method
TextWriter.WriteLine(System.String) Method
TextWriter.WriteLine(System.Object) Method
TextWriter.WriteLine(float) Method
TextWriter.WriteLine(System.String, System.Object) Method
TextWriter.WriteLine(System.String, System.Object, System.Object) Method
TextWriter.WriteLine(System.String, System.Object, System.Object, System.Object) Method
TextWriter.WriteLine(System.String, System.Object[]) Method
TextWriter.WriteLine(double) Method

TextWriter Fields

TextWriter.Null Field

TextWriter Properties

TextWriter.Encoding Property
TextWriter.FormatProvider Property
TextWriter.NewLine Property


TextWriter(System.IFormatProvider) Constructor

protected TextWriter(IFormatProvider formatProvider);

Summary

Constructs and initializes a new instance of the TextWriter class with the specified format provider.

Parameters

formatProvider
A IFormatProvider object that supplies a formatting object.

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter() Constructor

protected TextWriter();

Summary

Constructs and initializes a new instance of the TextWriter class.

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Close Method

public virtual void Close();

Summary

Closes the current TextWriter instance and releases any system resources associated with it.

Description

[Note: After a call to System.IO.TextReader.Close , any operation on the current instance might throw an exception.

This version of System.IO.TextReader.Close is equivalent to System.IO.TextReader.Dispose(System.Boolean)(true ).

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Dispose Method

protected virtual void Dispose(bool disposing);

Summary

Releases the unmanaged resources used by the TextWriter and optionally releases the managed resources.

Parameters

disposing
true to release both managed and unmanaged resources; false to release only unmanaged resources.

Description

When the disposing parameter is true , this method releases all resources held by any managed objects that this FileStream references. This method invokes the Dispose() method of each referenced object.

[Note: System.IO.FileStream.Dispose(System.Boolean) can be called multiple times by other objects. When overriding System.IO.FileStream.Dispose(System.Boolean)(Boolean), be careful not to reference objects that have been previously disposed in an earlier call to System.IO.FileStream.Dispose(System.Boolean) .]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Flush Method

public virtual void Flush();

Summary

Writes any buffered data to the underlying device and clears all buffers for the current TextWriter instance.

Description

[Behaviors: As described above.]

[Default: This method is not implemented in this abstract class.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Synchronized Method

public static TextWriter Synchronized(TextWriter writer);

Summary

Creates a thread-safe wrapper around the specified TextWriter instance.

Parameters

writer
The TextWriter to synchronize.

Return Value

A thread-safe TextWriter .

Exceptions

Exception TypeCondition
ArgumentNullExceptionwriter is null .

Description

This method returns a class that wraps around the specified TextWriter instance and restricts concurrent access to it by multiple threads.

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.System.IDisposable.Dispose Method

void IDisposable.Dispose();

Summary

Implemented to support the IDisposable interface. [Note: For more information, see System.IDisposable.Dispose.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(System.String, System.Object[]) Method

public virtual void Write(string format, params object[] arg);

Summary

Writes a formatted string to the text stream.

Parameters

format
A String containing the format string.
arg
The array of objects referenced from the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat is null .

-or-

arg is null .

IOExceptionAn I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to arg. Length .

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)(System.String.Format(System.String,System.Object) (format, arg)).

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

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(System.String, System.Object, System.Object, System.Object) Method

public virtual void Write(string format, object arg0, object arg1, object arg2);

Summary

Writes out a formatted string to the text stream.

Parameters

format
A String containing the format string.
arg0
The first object referenced in the format string.
arg1
The second object referenced in the format string.
arg2
The third object referenced in the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat is null .

IOException An I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to the number of provided objects to be formatted (3).

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)(System.String.Format(System.String,System.Object) (format, arg0, arg1, arg2)).

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

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(System.String, System.Object, System.Object) Method

public virtual void Write(string format, object arg0, object arg1);

Summary

Writes out a formatted string to the text stream.

Parameters

format
A String containing the format string.
arg0
The first object referenced in the format string.
arg1
The second object referenced in the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat is null .

IOException An I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to the number of provided objects to be formatted (2).

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)(System.String.Format(System.String,System.Object) (format, arg0, arg1)).

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

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(System.String, System.Object) Method

public virtual void Write(string format, object arg0);

Summary

Writes out the format string to the text stream.

Parameters

format
A String containing the format string.
arg0
An object referenced in the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat is null .

IOExceptionAn I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to the number of provided objects to be formatted (1).

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)(System.String.Format(System.String,System.Object) (format, arg0)).

[Note: If the specified object is not referenced in the format string, it is ignored.

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(System.Object) Method

public virtual void Write(object value);

Summary

Writes the text representation of a specified object to the text stream.

Parameters

value
The object to write. If value is null , nothing is written.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString()).

[Behaviors: As described above.]

[Default: The default implementation uses the System.IO.TextWriter.Write(System.Char)(String) method.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(System.String) Method

public virtual void Write(string value);

Summary

Writes a specified String to the text stream.

Parameters

value
The String to write. If value is null , nothing is written.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)(value.ToByteArray()).

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

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(System.Decimal) Method

public virtual void Write(decimal value);

Summary

Writes the text representation of a specified Decimal to the text stream.

Parameters

value
The Decimal to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString ()).

[Behaviors: As described above.]

Library

ExtendedNumerics

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(double) Method

public virtual void Write(double value);

Summary

Writes the text representation of a specified Double to the text stream.

Parameters

value
The Double to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString()).

[Behaviors: As described above.]

Library

ExtendedNumerics

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(float) Method

public virtual void Write(float value);

Summary

Writes the text representation of a specified Single to the text stream.

Parameters

value
The Single to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString()).

[Behaviors: As described above.]

Library

ExtendedNumerics

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(ulong) Method

public virtual void Write(ulong value);

Summary

Writes the text representation of a specified UInt64 to the text stream.

Parameters

value
The UInt64 to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.IO.TextWriter.Write(System.Char)(Decimal).

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString () ).

[Behaviors: As described above.]

Attributes

CLSCompliantAttribute(false)

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(long) Method

public virtual void Write(long value);

Summary

Writes the text representation of a specified Int64 to the text stream.

Parameters

value
The Int64 to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString () ).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(uint) Method

public virtual void Write(uint value);

Summary

Writes the text representation of a UInt32 to the text stream.

Parameters

value
The UInt32 to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.IO.TextWriter.Write(System.Char)(Int64).

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString ()).

[Behaviors: As described above.]

Attributes

CLSCompliantAttribute(false)

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(int) Method

public virtual void Write(int value);

Summary

Writes the text representation of a specified Int32 to the text stream.

Parameters

value
The Int32 to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString ()).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(bool) Method

public virtual void Write(bool value);

Summary

Writes the text representation of a specified Boolean value to the text stream.

Parameters

value
The Boolean value to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToString ()).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(char[], int, int) Method

public virtual void Write(char[] buffer, int index, int count);

Summary

Writes a subarray of characters to the text stream.

Parameters

buffer
The character array from which characters are read.
index
Starting index in the buffer.
count
The number of characters to write.

Exceptions

Exception TypeCondition
ArgumentNullExceptionbuffer is null .
ArgumentException(index + count ) > buffer. Length.
ArgumentOutOfRangeExceptionindex < 0 or count < 0.
IOExceptionAn I/O error occurred.

Description

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

[Behaviors: As described above.]

[Default: The default implementation uses the System.IO.TextWriter.Write(System.Char)(char []) method.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(char[]) Method

public virtual void Write(char[] buffer);

Summary

Writes a character array to the text stream.

Parameters

buffer
The Char array to write to the text stream. If buffer is null , nothing is written.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)(buffer, 0, buffer.Length ).

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

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Write(char) Method

public virtual void Write(char value);

Summary

Writes a character to the text stream.

Parameters

value
The Char to write to the text stream.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

[Behaviors: As described above.]

[Default: This method is not implemented in this abstract class.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(System.Decimal) Method

public virtual void WriteLine(decimal value);

Summary

Writes the text representation of a specified Decimal value followed by a line terminator to the text stream.

Parameters

value
The Decimal value to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine (value.ToString()).

[Behaviors: As described above.]

Library

ExtendedNumerics

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(long) Method

public virtual void WriteLine(long value);

Summary

Writes the text representation of a specified Int64 value followed by a line terminator to the text stream.

Parameters

value
The Int64 value to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine( value.ToString () ).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(uint) Method

public virtual void WriteLine(uint value);

Summary

Writes the text representation of a specified UInt32 value followed by a line terminator to the text stream.

Parameters

value
The UInt32 value to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.IO.TextWriter.WriteLine(Int64).

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine( value.ToString () ).

[Behaviors: As described above.]

Attributes

CLSCompliantAttribute(false)

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(int) Method

public virtual void WriteLine(int value);

Summary

Writes the text representation of a specified Int32 value followed by a line terminator to the text stream.

Parameters

value
The Int32 value to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine(value.ToString()).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(bool) Method

public virtual void WriteLine(bool value);

Summary

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

Parameters

value
The Boolean value to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine( value.ToString () ).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(char[], int, int) Method

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

Summary

Writes a sub-array of characters from a specified character array, followed by a line terminator to the text stream.

Parameters

buffer
The Char array from which characters are read.
index
A Int32 that specifies the index in buffer at which to begin reading.
count
A Int32 that specifies the maximum number of characters to write.

Exceptions

Exception TypeCondition
ArgumentNullExceptionbuffer is null .
ArgumentException(index + count ) > buffer.Length.
ArgumentOutOfRangeExceptionindex < 0

-or-

count < 0.

IOExceptionAn I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.Write(System.Char)( value, index, count ) followed by System.IO.TextWriter.WriteLine().

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

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(char[]) Method

public virtual void WriteLine(char[] buffer);

Summary

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

Parameters

buffer
The Char array from which data is read. If buffer is null , only the line terminator is written.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.Write(System.Char)( value ) followed by System.IO.TextWriter.WriteLine().

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

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(char) Method

public virtual void WriteLine(char value);

Summary

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

Parameters

value
The Char to write to the text stream.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.Write(System.Char)( value ) followed by System.IO.TextWriter.WriteLine().

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine() Method

public virtual void WriteLine();

Summary

Writes a line terminator to the text stream.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.Write(System.Char)(System.IO.TextWriter.NewLine.ToCharArray()).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(ulong) Method

public virtual void WriteLine(ulong value);

Summary

Writes the text representation of a specified UInt64 value followed by a line terminator to the text stream.

Parameters

value
The UInt64 value to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This member is not CLS-compliant. For a CLS-compliant alternative, use System.IO.TextWriter.WriteLine(Decimal).

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine( value.ToString () ).

[Behaviors: As described above.]

Attributes

CLSCompliantAttribute(false)

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(System.String) Method

public virtual void WriteLine(string value);

Summary

Writes a specified String followed by a line terminator to the text stream.

Parameters

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

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.Write(System.Char) is equivalent to System.IO.TextWriter.Write(System.Char)( value.ToByteArray() ).

The line terminator string is defined by the System.IO.TextWriter.NewLine property.

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

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(System.Object) Method

public virtual void WriteLine(object value);

Summary

Writes the text representation of a specified object followed by a line terminator to the text stream.

Parameters

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

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine( value.ToString() ).

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(float) Method

public virtual void WriteLine(float value);

Summary

Writes the text representation of a specified Single value followed by a line terminator to the text stream.

Parameters

value
The Single value to write.

Exceptions

Exception TypeCondition
IOExceptionAn I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine(value.ToString()).

[Behaviors: As described above.]

Library

ExtendedNumerics

See Also

System.IO.TextWriter Class, System.IO Namespace

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

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

Summary

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

Parameters

format
A String containing the format string.
arg0
The object referenced in the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat is null .

IOExceptionAn I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to the number of provided objects to be formatted (1).

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine(System.String.Format(System.String,System.Object) (format, arg0)).

[Note: If the specified object is not referenced in the format string, it is ignored.

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

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

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

Summary

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

Parameters

format
A String containing the format string.
arg0
The first object referenced in the format string.
arg1
The second object referenced in the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat is null .

IOExceptionAn I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to the number of provided objects to be formatted (2).

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine(System.String.Format(System.String,System.Object) (format, arg0, arg1)).

[Note: If the specified object is not referenced in the format string, it is ignored.

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

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

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

Summary

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

Parameters

format
A String containing the format string.
arg0
The first object referenced in the format string.
arg1
The second object referenced in the format string.
arg2
The third object referenced in the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat is null .

IOExceptionAn I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to the number of provided objects to be formatted (3).

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine(System.String.Format(System.String,System.Object) (format, arg0, arg1, arg2)).

If the value of any object parameter is null, it is treated as an empty string.

[Note: If the specified object is not referenced in the format string, it is ignored.

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(System.String, System.Object[]) Method

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

Summary

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

Parameters

format
A String containing the format string.
arg
The array of objects referenced from the format string.

Exceptions

Exception TypeCondition
ArgumentNullExceptionformat or arg is null .
IOExceptionAn I/O error occurred.
FormatExceptionThe format specification in format is invalid.

-or-

The number indicating an argument to be formatted is less than zero, or greater than or equal to arg. Length.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine(System.String.Format(System.String,System.Object) (format, arg)).

[Note: If the specified object is not referenced in the format string, it is ignored.

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

]

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.WriteLine(double) Method

public virtual void WriteLine(double value);

Summary

Writes the text representation of a specified Double value followed by a line terminator to the text stream.

Parameters

value
The Double value to write.

Exceptions

Exception TypeCondition
IOException An I/O error occurred.

Description

This version of System.IO.TextWriter.WriteLine is equivalent to System.IO.TextWriter.WriteLine (value.ToString()).

[Behaviors: As described above.]

Library

ExtendedNumerics

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Null Field

public static readonly TextWriter Null;

Summary

Provides a TextWriter object without a backing store.

Description

Use System.IO.TextWriter.Null to redirect output to a stream that will not consume any operating system resources.

When a System.IO.TextWriter.Write(System.Char) method is invoked on System.IO.TextWriter.Null, the call simply returns, and no data is actually written to any backing store.

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.Encoding Property

public abstract Encoding Encoding { get; }

Summary

Gets the Encoding in which the output is written.

Property Value

The Encoding in which the output is written.

Description

[Behaviors: As described above.]

[Usage: This property is required in some XML scenarios where a header must be written containing the encoding used by the TextWriter. This allows XML code to consume an arbitrary TextWriter and generate a correct XML header.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.FormatProvider Property

public virtual IFormatProvider FormatProvider { get; }

Summary

Gets an object that provides formatting for the current instance

Property Value

A IFormatProvider object for a specific culture, or the formatting of the current culture if no other culture is specified.

Description

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace

TextWriter.NewLine Property

public virtual string NewLine { get; set; }

Summary

Gets or sets the line terminator string used by the current TextWriter .

Property Value

A String containing the line terminator string for the current TextWriter .

Description

The default line terminator string is System.Environment.NewLine .

The line terminator string is written to the text stream whenever one of the System.IO.TextWriter.WriteLine methods is called. In order for text written by the TextWriter to be readable by a TextReader , only System.Environment.NewLine should be used as a terminator string. If System.IO.TextWriter.NewLine is set to null , the default newline character is used instead.

[Behaviors: As described above.]

See Also

System.IO.TextWriter Class, System.IO Namespace