.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

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -