将此实例的子字符串中所有指定字符的匹配项替换为其他指定字符。 

命名空间: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 

以上就是【c# StringBuilder.Replace 方法 (Char, Char, Int32, Int32)】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论