1.Length:(整型int)字符串长度 计算str中一共有几个字符
string str = "Hello World";
Console.WriteLine(str.ToLength());
2.Trim():(string)压缩字符串两边的空格
string a = " 你好 ";
Console.WriteLine(a.Trim());
3.ToUpper():(string)把字符串全部变成大写
string a = "lizhen";
Console.WriteLine(a.ToUpper());
4.ToLower():(string)把字符串全部变成小写
string a = "lizhen";
Console.WriteLine(a.ToLower());
5.StartWith("子串"):(bool)是否以“子串”开头
string a = "371329199410023315";
Console.WriteLine(a.StartsWith("3713"));
6.EndWith("子串"):(bool)是否以“子串”结尾
string a = "371329199410023315";
Console.WriteLine(a.Endwith(“3315”));
7.Contains("子串"):(bool)是否包含“子串”
string a = "371329199410023315";
Console.WriteLine(a.Contains("19941002"));
8.IndexOf("子串"):(int)子串第一次出现的位置.从0开始数
string a = "371329199410023315";
int b = a.IndexOf("1");
Console.WriteLine(b);
表示从第二位开始出现
9.LastIndexOf("子串"):(int)子串最后一次出现的位置。从0开始数
string a = "371329199410023315";
int b = a.LastIndexOf("1");
Console.WriteLine(b);
10.Substring(起始位置[,截取长度]):(string)在字符串中截取子串出来。
string a = "371329199410023315";
string b = a.Substring(6,8);
Console.WriteLine(b);
表示从第六位开始截取后面八位数