标签:删除 console 拆分 start 截取 技术 spl png 返回
目录
String.Empty的内部实现:
public static readonly String Empty = "";
所以String.Empty的内部实现是相同于""的,一般使用是可以把这俩化为等号的
string对象的值存储在堆上,栈上存储的是值在堆中的地址。
""在堆和栈中都会分配内存。
null只会在栈中分配内存。
string str1 = "Ffly"; string str2 = "f e i "; //获取字符串长度 Console.WriteLine(str1.Length); //返回指定的字符串第一次出现的位置,没有则返回-1 Console.WriteLine(str1.IndexOf(‘f‘)); //返回指定的字符串最后一次出现的位置,没有则返回-1 Console.WriteLine(str1.LastIndexOf(‘f‘)); //判断某个字符串是否以指定的字符串开头 Console.WriteLine(str1.StartsWith("Ff")); //判断某个字符串是否以指定的字符串结尾 Console.WriteLine(str1.EndsWith("f")); //全部转小写 Console.WriteLine(str1.ToLower()); //全部转大写 Console.WriteLine(str1.ToUpper()); //不带参数则删除开头结尾所有空格 Console.WriteLine(str2.Trim()); //删除开头开头结尾所有指定字符 Console.WriteLine(str2.Trim("fi".ToCharArray())); //TrimStart和TrimEnd同理 //删除指定位置字符 Console.WriteLine(str2.Remove(2)); Console.WriteLine(str2.Remove(2,2)); //拆分字符串 str2.Split(‘ ‘); //替换字符串 str2.Replace("f", "fff"); //截取字符串 str2.Substring(2); str2.Substring(2,2); //字符串插入 str2.Insert(1, "fff");
参考于https://blog.csdn.net/henulwj/article/details/7830615
参考于http://c.biancheng.net/view/2832.html
标签:删除 console 拆分 start 截取 技术 spl png 返回
原文地址:https://www.cnblogs.com/Fflyqaq/p/12878041.html