.net - Indexing into a String in C# as an L-Value -
i have following intentionally trivial function:
void replacesome(ref string text) { stringbuilder sb = new stringbuilder(text); sb[5] = 'a'; text = sb.tostring(); }
it appears inefficient convert stringbuilder index , replace of characters copy ref'd param. possible index directly text param l-value?
or how else can improve this?
c# strings "immutable," means can't modified. if have string, , want similar different string, must create new string. using stringbuilder above easy method any.
Comments
Post a Comment