Skip to main content

Remove All Redundant Block Delimiters

Purpose

Used to remove redundant block delimiters throughout the method.

Availability

Available when the cursor is at the beginning of a method declaration.

Usage

  1. Place the caret at the beginning of a method declaration.

    Note

    The blinking cursor shows the caret’s position at which the Code Formatter is available.

    static void Main(string[] args) {
        Console.Write("Even numbers:");
        for (int i = 1; i <= 10; i++) {
            if (i % 2 == 0) {
                Console.Write($" {i}");
            }
        }
        Console.ReadKey();
    }
    
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Remove All Redundant Block Delimiters from the menu.

After execution, the Code Formatter removes all redundant block delimiters in the method.

static void Main(string[] args) {
    Console.Write("Even numbers:");
    for (int i = 1; i <= 10; i++)
        if (i % 2 == 0)
            Console.Write($" {i}");
    Console.ReadKey();
}
See Also