2025年c语言_c ref

c语言_c refStringBuilde 用于大量的字符串的修改的地方 比如要大量的连接字符串时 使用它能节省内存空间 StringBuilde testStr new StringBuilde abcdef ggg testStr AppendFormat s testStr Append s int len testStr

StringBuilder 用于大量的字符串的修改的地方,比如要大量的连接字符串时,使用它能节省内存空间。

        StringBuilder  testStr = new StringBuilder ( "abcdef:ggg");
//testStr.AppendFormat($"{ s}");
testStr.Append ($"{ s}");

int len = testStr.Length;

char[] charArray=new char[len ] ;
testStr.CopyTo(0, charArray, 0, testStr.Length);//将指定长度的字符复制到字符数组中
testStr.Insert(0, 'w');
testStr.Insert(0, "?",2);//插入指定数量的字符串
testStr.Insert(0, new char[] { 'o','p'}, 0,1);//插入字符数组中指定起始位置,指定长度的字符数组
testStr.Remove(0, 1);
testStr.Replace('b', 'l');

testStr.Replace("??", "::",2,2);//从testStr指定的字符位置、指定的字符串长度进行替换。
testStr.Replace("??", "::");
testStr.Clear();

编程小号
上一篇 2025-02-19 15:17
下一篇 2025-07-25 23:30

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/hz/132285.html