IProjectionBufferBase.Replace 方法

用不同文本替换字符范围。 此方法等效于先删除要替换的文本,再插入新文本。

命名空间:  Microsoft.VisualStudio.Text.Projection
程序集:  Microsoft.VisualStudio.Text.Data(在 Microsoft.VisualStudio.Text.Data.dll 中)

语法

声明
Function Replace ( _
    replaceSpan As Span, _
    replaceWith As String _
) As IProjectionSnapshot
IProjectionSnapshot Replace(
    Span replaceSpan,
    string replaceWith
)
IProjectionSnapshot^ Replace(
    Span replaceSpan, 
    String^ replaceWith
)
abstract Replace : 
        replaceSpan:Span * 
        replaceWith:string -> IProjectionSnapshot
function Replace(
    replaceSpan : Span, 
    replaceWith : String
) : IProjectionSnapshot

参数

  • replaceWith
    类型:String

    新文本。

返回值

类型:Microsoft.VisualStudio.Text.Projection.IProjectionSnapshot
一个 IProjectionSnapshot

异常

异常 条件
ArgumentNullException

replaceWith 为 nullnull 引用(在 Visual Basic 中为 Nothing)。

ArgumentOutOfRangeException

replaceSpan 范围的结束位置大于缓冲区的长度时。

InvalidOperationException

ITextEdit 是当前活动的。

备注

这是创建一个新 ITextEdit 对象的快捷方式,则替换中的文本,然后应用。 如果替换因只读区域而失败,则返回的快照与该缓冲区的当前快照中所尝试的替换之前。

.NET Framework 安全性

请参阅

参考

IProjectionBufferBase 接口

Microsoft.VisualStudio.Text.Projection 命名空间