Back to Devexpress

Split String

coderushforroslyn-116894-refactoring-assistance-split-string.md

latest1.1 KB
Original Source

Split String

  • Aug 03, 2020

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

  1. 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.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Split String from the menu.

After execution, the Refactoring splits the string into two or three concatenated strings.

csharp
Console.WriteLine("User: " + "admin");
vb
Console.WriteLine("User: " & "admin")

See Also

Convert to String Interpolation

Use String Builder