C# · 12月 19, 2021

js实现C#的StringBuilder效果完整实例

本文实例讲述了js实现C#的StringBuilder效果。分享给大家供大家参考,具体如下:

s.length){h[0]=s;} else { h[0]=s.substring(0,startIndex); h[1]=s.substring(startIndex+length,s.length); } return this; } // Inserts the string representation of a specified object into this instance at a specified character position. // Parameter[“index”] – The position at which to insert. // Parameter[“value”] – The string to insert. // Return Value – A reference to this instance after the insert operation has occurred. function Insert(index,value) { var s = h.join(”); h = new Array(); if(index=s.length){h[0]=s; h[1]=value;} else { h[0]=s.substring(0,index); h[1]=value; h[2]=s.substring(index,s.length); } return this; } // Gets the type function GetType() { return “StringBuilder”; }};

希望本文所述对大家JavaScript程序设计有所帮助。