TextExtensions.CopyToString(TextRange) Method

Definition

Copies the TextRange to a string.

public static string CopyToString (this Microsoft.VisualStudio.Extensibility.Editor.TextRange text);
static member CopyToString : Microsoft.VisualStudio.Extensibility.Editor.TextRange -> string
<Extension()>
Public Function CopyToString (text As TextRange) As String

Parameters

text
TextRange

Returns

A non-null string.

Remarks

Copying text from a large range to a string is very expensive and should be avoided.

  • You can use TextPosition and TextRange to represent substrings in a document without expending resources copying or allocating strings. Most APIs operate in terms of these primitives.
  • You can use the indexer syntax on TextRange, to read or compare character by character in a document without copying it to a string.

Applies to