1、Trim()
检查字符串首尾空格符,返回一个新字符串,但不改变原字符串。
eg: string s1=" www.baidu.con ";
print(s1); ----------(1)
s1.Trim();
print(s1); ----------(2)
输出结果(1)(2)仍为 s1 一样;
string s1=" www.baidu.com ";
print(s1);
s2=s1.Trim();
print(s2);
此时输出s2就为去掉首尾空格的结果。
去除字符中间的空格: str.Replace(" ","")
2、 IndexOf()
查找字符串中是否有指定字符或字符串,返回首个字符地址(int)
eg: string s="www.baidu.com ";
int index = s.IndexOf("du");
print(index); //从0开始 而且是首次出现匹配
3、 LastIndexOf()
在字符串中查找指定字符或指定字符串最后一次出现的位置。
4、 Substring(int starIndex,int endIndex)
5、 ToLower() ToUpper()
6、 StartsWith EndsWith