String.SubString(int index,int length)
index:開始位置,從0開始
length:你要取的子字符串的長度
幾個經常用到的: 1、取字符串的前i個字符 (1)string str1=str.Substring(0,i); (2)string str1=str.Remove(i,str.Length-i); 2、去掉字符串的前i個字符 string str1=str.Remove(0,i); string str1=str.SubString(i); 3、從右邊開始取i個字符: string str1=str.SubString(str.Length-i); string str1=str.Remove(0,str.Length-i); 4、從右邊開始去掉i個字符: string str1=str.Substring(0,str.Length-i); string str1=str.Remove(str.Length-i,i); 5 、如果字符串中有"abc"則替換成"ABC" str=str.Replace("abc","ABC"); 6、c#截取字符串最后一個字符的問題!!!!!!!!!!!!!!!!!!!!! str1.Substring(str1.LastIndexOf(",")+1); 7、C# 截取字符串最后一個字符 k = k.Substring(k.Length-1, 1);