移除字符串部分:
Remove() – 删除一部分子字符串
Remove 有两种形式:
Remove(int startIndex)
删除此字符串中从指定位置到最后位置的所有字符。
Remove(int startIndex, int length)
从此实例中的指定位置开始删除指定数目的字符。
// 取从第 10 个开始长度为 10 的子串
var sliceUsingSubstring = test.Substring(10, 10);
// 获取从 length - 10 到最后的部分.
var sliceUsingSubstring = test.Substring(test.Length - 10);
Replace(string oldValue, string newValue)
将此实例中的指定 String 的所有匹配项替换为其他指定的 String。
Remove() – 删除一部分子字符串
Remove 有两种形式:
Remove(int startIndex)
删除此字符串中从指定位置到最后位置的所有字符。
Remove(int startIndex, int length)
从此实例中的指定位置开始删除指定数目的字符。
// 取从第 10 个开始长度为 10 的子串
var sliceUsingSubstring = test.Substring(10, 10);
// 获取从 length - 10 到最后的部分.
var sliceUsingSubstring = test.Substring(test.Length - 10);
Replace(string oldValue, string newValue)
将此实例中的指定 String 的所有匹配项替换为其他指定的 String。
String str="abc#def#hijkl#mn"; string[] s = str.Split(new char[] { '#' });