2014-06-17學習筆記

移除字符串部分:
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[] { '#' });

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章