Split String
Purpose
This Refactoring divides a string into two parts at the caret position or three parts by extracting the selected text. This is helpful when you need to replace a part of a string with a variable.
Availability
Available when the caret is within a string literal or a part of a string is selected.
Usage
Place the caret into a string literal. You can also divide one string into three concatenated strings by selecting the part you need to separate.
Note
The blinking cursor shows the caret’s position at which the Refactoring is available.
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
- Select Split String from the menu.
After execution, the Refactoring splits the string into two or three concatenated strings.
See Also