Use Environment.NewLine

Purpose

Replaces the "\r\n" string with the Environment.NewLine constant reference.

Availability

Available when the cursor is on the "\r\n" string.

Not available when the "\r\n" string is a part of another string.

Usage

  1. Place the caret on the "\r\n" string.

    Note

    The blinking cursor shows the caret's position at which the Refactoring is available.

    string hello = "Hello World !!!" + "\r\n";
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Use Environment.NewLine from the menu.

After execution, the Refactoring replaces the "\r\n" string with the Environment.NewLine constant reference.

string hello = "Hello World !!!" + Environment.NewLine;
See Also