判断某个字符串是否包含某个字符串:str.contains
tring str = "hello";
bool b = str.Contains("el");
Console.WriteLine(b);
是否已某一个字符串结尾:str.endswith
str.EndsWith("o");
是否以某个字符串开始:str.startwith
str.StartsWith("q");
右对齐:str.padleft
string newstr = str.PadLeft(15);
Console.WriteLine(newstr);
string str1 = "china";
string str2 = "english";
Console.WriteLine(str1.PadLeft(5));
Console.WriteLine(str2.PadLeft(5));
替换
string str3 = str.Replace("ll", "a");
Console.WriteLine(str3);
转换为大写
string str4 = str.ToUpper();
Console.WriteLine(str4);
从当前的字符串中去移除头部和尾部的空白字符:str.Trim
string str = " hello world ";
string str1 = str.Trim();
Console.WriteLine(str1);
截取子字符串:第4个字符开始,总共4个字符
string str2 = str1.Substring(4, 4);
Console.WriteLine(str2);