Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Replaces a sequence of characters with different text.
Namespace:  Microsoft.VisualStudio.Text
Assembly:  Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)
Syntax
'Declaration
Function Replace ( _
    startPosition As Integer, _
    charsToReplace As Integer, _
    replaceWith As String _
) As Boolean
bool Replace(
    int startPosition,
    int charsToReplace,
    string replaceWith
)
bool Replace(
    int startPosition, 
    int charsToReplace, 
    String^ replaceWith
)
abstract Replace : 
        startPosition:int * 
        charsToReplace:int * 
        replaceWith:string -> bool 
function Replace(
    startPosition : int, 
    charsToReplace : int, 
    replaceWith : String
) : boolean
Parameters
- startPosition
 Type: System.Int32
 The buffer position at which to start replacing.
- charsToReplace
 Type: System.Int32
 The number of characters to replace.
- replaceWith
 Type: System.String
 The new text.
Return Value
Type: System.Boolean
true if the replacement succeeded; false if it was prevented by a read-only region.
Exceptions
| Exception | Condition | 
|---|---|
| ArgumentNullException | replaceWith is null. | 
| InvalidOperationException | The Apply or Cancel or Dispose method has previously been called on this object. | 
| ArgumentOutOfRangeException | startPosition is less than zero or greater than the length of the buffer, or charsToReplace is less than zero, or startPosition + charsToReplace is greater than the length of the buffer. | 
Remarks
This method has the same effect as first deleting the charsToReplace and then inserting replaceWith.
Replacing zero characters with an empty string will succeed but will not generate a new snapshot or raise a Changed event.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.