This documentation is archived and is not being maintained.

TextWriter.NewLine Property

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

[Visual Basic]
Public Overridable Property NewLine As String
[C#]
public virtual string NewLine {get; set;}
[C++]
public: __property virtual String* get_NewLine();
public: __property virtual void set_NewLine(String*);
[JScript]
public function get NewLine() : String;
public function set NewLine(String);

Property Value

The line terminator string for the current TextWriter.

Remarks

The default line terminator string is a carriage return followed by a line feed ("\r\n").

The line terminator string is written to the text stream whenever one of the WriteLine methods is called. In order for text written by the TextWriter to be readable by a TextReader, only "\n" or "\r\n" should be used as terminator strings. If NewLine is set to a null reference (Nothing in Visual Basic), the default newline character is used instead.

The following table lists examples of other typical or related I/O tasks.

To do this... See the example in this topic...
Create a text file. Writing Text to a File
Write to a text file. Writing Text to a File
Read from a text file. Reading Text from a File

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

TextWriter Class | TextWriter Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File

Show: