c# StringBuilder.Replace 方法 (Char, Char, Int32, Int32)
更新時間:2007年08月18日 22:49:04 作者:
將此實例的子字符串中所有指定字符的匹配項替換為其他指定字符。
命名空間:System.Text
程序集:mscorlib(在 mscorlib.dll 中)
語法
C#
public StringBuilder Replace (
char oldChar,
char newChar,
int startIndex,
int count
)
參數(shù)
oldChar
要替換的字符。
newChar
替換 oldChar 的字符。
startIndex
此實例中子字符串開始的位置。
count
子字符串的長度。
返回值
對此實例的引用,其中從 startIndex 到 startIndex + count -1 范圍內(nèi)的 oldChar 被 newChar 替換。
異常
異常類型 條件
ArgumentOutOfRangeException
startIndex+count 大于此實例值的長度。
- 或 -
startIndex 或 count 小于零。
備注
StringBuilder 的大小不變,這是因為只是替換字符。此方法區(qū)分大小寫。
平臺
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 并不是對每個平臺的所有版本都提供支持。有關(guān)受支持版本的列表,請參見系統(tǒng)要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
命名空間:System.Text
程序集:mscorlib(在 mscorlib.dll 中)
語法
C#
public StringBuilder Replace (
char oldChar,
char newChar,
int startIndex,
int count
)
參數(shù)
oldChar
要替換的字符。
newChar
替換 oldChar 的字符。
startIndex
此實例中子字符串開始的位置。
count
子字符串的長度。
返回值
對此實例的引用,其中從 startIndex 到 startIndex + count -1 范圍內(nèi)的 oldChar 被 newChar 替換。
異常
異常類型 條件
ArgumentOutOfRangeException
startIndex+count 大于此實例值的長度。
- 或 -
startIndex 或 count 小于零。
備注
StringBuilder 的大小不變,這是因為只是替換字符。此方法區(qū)分大小寫。
平臺
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 并不是對每個平臺的所有版本都提供支持。有關(guān)受支持版本的列表,請參見系統(tǒng)要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
您可能感興趣的文章:
- C#與C++?dll之間傳遞字符串string?wchar_t*?char*?IntPtr問題
- C#?BitArray(點矩陣)轉(zhuǎn)換成int和string的方法實現(xiàn)
- C#開發(fā)之int與string轉(zhuǎn)化操作
- C#中BitConverter.ToUInt16()和BitConverter.ToString()的簡單使用
- C# 6.0 內(nèi)插字符串(Interpolated Strings )的使用方法
- C#中字符串優(yōu)化String.Intern、IsInterned詳解
- C#中把字符串String轉(zhuǎn)換為整型Int的小例子
- C#中String轉(zhuǎn)int的四種方法
相關(guān)文章
C#開發(fā)之int與string轉(zhuǎn)化操作
這篇文章主要介紹了C#開發(fā)之int與string轉(zhuǎn)化操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-12-12