c# StringBuilder.Replace 方法 (Char, Char, Int32, Int32)

 更新时间:2020年6月25日 11:44  点击:2069
将此实例的子字符串中所有指定字符的匹配项替换为其他指定字符。 

命名空间:System.Text 
程序集:mscorlib(在 mscorlib.dll 中) 

语法 
C# 
public StringBuilder Replace ( 
char oldChar, 
char newChar, 
int startIndex, 
int count 

参数 
oldChar 
要替换的字符。 

newChar 
替换 oldChar 的字符。 

startIndex 
此实例中子字符串开始的位置。 

count 
子字符串的长度。 

返回值 
对此实例的引用,其中从 startIndex 到 startIndex + count -1 范围内的 oldChar 被 newChar 替换。 
异常 
异常类型 条件 
ArgumentOutOfRangeException 
startIndex+count 大于此实例值的长度。 

- 或 - 

startIndex 或 count 小于零。 


备注 
StringBuilder 的大小不变,这是因为只是替换字符。此方法区分大小写。 

平台 
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、
Windows Mobile for Pocket PC、Windows Mobile for Smartphone、
Windows Server 2003、Windows XP Media Center Edition、
Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition 

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。


版本信息 
.NET Framework 
受以下版本支持:2.0、1.1、1.0 
[!--infotagslink--]

相关文章

  • c# StringBuilder.Replace 方法 (Char, Char, Int32, Int32)

    将此实例的子字符串中所有指定字符的匹配项替换为其他指定字符。 命名空间:System.Text 程序集:mscorlib(在 mscorlib.dll 中) 语法 C# public StringBuilder Replac...2020-06-25
  • postgresql 中的to_char()常用操作

    这篇文章主要介绍了postgresql 中的to_char()常用操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-02-01