Search Results for

    Show / Hide Table of Contents

    Class TextWriter

    Represents a writer that can write a sequential series of characters. This class is abstract.

    Inheritance
    object
    MarshalByRefObject
    TextWriter
    StreamWriter
    Implements
    IDisposable
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: System.IO
    Assembly: System.IO.Streams.dll
    Syntax
    public abstract class TextWriter : MarshalByRefObject, IDisposable

    Constructors

    TextWriter()

    Declaration
    protected TextWriter()

    Fields

    CoreNewLine

    Stores the newline characters used for this TextWriter.

    Declaration
    protected char[] CoreNewLine
    Field Value
    Type Description
    char[]

    Properties

    Encoding

    When overridden in a derived class, returns the character encoding in which the output is written.

    Declaration
    public abstract Encoding Encoding { get; }
    Property Value
    Type Description
    Encoding

    NewLine

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

    Declaration
    public virtual string NewLine { get; set; }
    Property Value
    Type Description
    string

    Methods

    Close()

    Closes the current writer and releases any system resources associated with the writer.

    Declaration
    public virtual void Close()

    Dispose()

    Releases all resources used by the TextWriter object.

    Declaration
    public void Dispose()

    Dispose(bool)

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

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing

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

    Flush()

    Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

    Declaration
    public virtual void Flush()
    Remarks

    This default method does nothing, but derived classes can override the method to provide the appropriate functionality.

    Flushing the stream will not flush its underlying encoder unless you explicitly call Flush() or Close(). Setting AutoFlush to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.

    Write(bool)

    Writes the text representation of a bool value to the text stream.

    Declaration
    public virtual void Write(bool value)
    Parameters
    Type Name Description
    bool value

    The bool value to write.

    Write(char)

    Writes a character to the text stream.

    Declaration
    public virtual void Write(char value)
    Parameters
    Type Name Description
    char value

    The character to write to the text stream.

    Write(char[], int, int)

    Writes a subarray of characters to the text stream.

    Declaration
    public virtual void Write(char[] buffer, int index, int count)
    Parameters
    Type Name Description
    char[] buffer

    The character array to write data from.

    int index

    The character position in the buffer at which to start retrieving data.

    int count

    The number of characters to write.

    Exceptions
    Type Condition
    ArgumentNullException

    The buffer parameter is null.

    ArgumentOutOfRangeException

    index or count is negative.

    ArgumentException

    The buffer length minus index is less than count.

    Write(char[])

    Writes a character array to the text stream.

    Declaration
    public virtual void Write(char[] buffer)
    Parameters
    Type Name Description
    char[] buffer

    The character array to write to the text stream.

    Write(double)

    Writes the text representation of an 8-byte floating-point value to the text stream.

    Declaration
    public virtual void Write(double value)
    Parameters
    Type Name Description
    double value

    The 8-byte floating-point value to write.

    Write(int)

    Writes the text representation of a 4-byte signed integer to the text stream.

    Declaration
    public virtual void Write(int value)
    Parameters
    Type Name Description
    int value

    The 4-byte signed integer to write.

    Write(long)

    Writes the text representation of an 8-byte signed integer to the text stream.

    Declaration
    public virtual void Write(long value)
    Parameters
    Type Name Description
    long value

    The 8-byte signed integer to write.

    Write(object)

    Writes the text representation of an object to the text stream by calling the ToString() method on that object.

    Declaration
    public virtual void Write(object value)
    Parameters
    Type Name Description
    object value

    The object to write.

    Write(float)

    Writes the text representation of a 4-byte floating-point value to the text stream.

    Declaration
    public virtual void Write(float value)
    Parameters
    Type Name Description
    float value

    The 4-byte floating-point value to write.

    Write(string)

    Writes a string to the text stream.

    Declaration
    public virtual void Write(string value)
    Parameters
    Type Name Description
    string value

    The string to write.

    Write(uint)

    Writes the text representation of a 4-byte unsigned integer to the text stream.

    Declaration
    [CLSCompliant(false)]
    public virtual void Write(uint value)
    Parameters
    Type Name Description
    uint value

    The 4-byte unsigned integer to write.

    Write(ulong)

    Writes the text representation of an 8-byte unsigned integer to the text stream.

    Declaration
    [CLSCompliant(false)]
    public virtual void Write(ulong value)
    Parameters
    Type Name Description
    ulong value

    The 8-byte unsigned integer to write.

    WriteLine()

    Writes a line terminator to the text stream.

    Declaration
    public virtual void WriteLine()

    WriteLine(bool)

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

    Declaration
    public virtual void WriteLine(bool value)
    Parameters
    Type Name Description
    bool value

    The bool value to write.

    WriteLine(char)

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

    Declaration
    public virtual void WriteLine(char value)
    Parameters
    Type Name Description
    char value

    The character to write to the text stream.

    WriteLine(char[], int, int)

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

    Declaration
    public virtual void WriteLine(char[] buffer, int index, int count)
    Parameters
    Type Name Description
    char[] buffer

    The character array to write data from.

    int index

    The character position in the buffer at which to start retrieving data.

    int count

    The number of characters to write.

    Exceptions
    Type Condition
    ArgumentNullException

    The buffer parameter is null.

    ArgumentOutOfRangeException

    index or count is negative.

    ArgumentException

    The buffer length minus index is less than count.

    WriteLine(char[])

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

    Declaration
    public virtual void WriteLine(char[] buffer)
    Parameters
    Type Name Description
    char[] buffer

    The character array to write to the text stream.

    WriteLine(double)

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

    Declaration
    public virtual void WriteLine(double value)
    Parameters
    Type Name Description
    double value

    The 8-byte floating-point value to write.

    WriteLine(int)

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

    Declaration
    public virtual void WriteLine(int value)
    Parameters
    Type Name Description
    int value

    The 4-byte signed integer to write.

    WriteLine(long)

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

    Declaration
    public virtual void WriteLine(long value)
    Parameters
    Type Name Description
    long value

    The 8-byte signed integer to write.

    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.

    Declaration
    public virtual void WriteLine(object value)
    Parameters
    Type Name Description
    object value

    The object to write.

    WriteLine(float)

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

    Declaration
    public virtual void WriteLine(float value)
    Parameters
    Type Name Description
    float value

    The 4-byte floating-point value to write.

    WriteLine(string)

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

    Declaration
    public virtual void WriteLine(string value)
    Parameters
    Type Name Description
    string value

    The string to write.

    WriteLine(uint)

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

    Declaration
    [CLSCompliant(false)]
    public virtual void WriteLine(uint value)
    Parameters
    Type Name Description
    uint value

    The 4-byte unsigned integer to write.

    WriteLine(ulong)

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

    Declaration
    [CLSCompliant(false)]
    public virtual void WriteLine(ulong value)
    Parameters
    Type Name Description
    ulong value

    The 8-byte unsigned integer to write.

    Implements

    IDisposable

    Extension Methods

    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    LogDispatcher.GetCurrentClassLogger(object)
    In This Article
    Back to top Copyright © 2023 nanoFramework Contributors
    Generated by DocFX