Does StringBuilder become immutable after a call to ToString?

前端 未结 5 777
面向向阳花
面向向阳花 2021-01-01 19:09

I distinctly remember from the early days of .NET that calling ToString on a StringBuilder used to provide the new string object (to be returned) with the internal char buff

5条回答
  •  礼貌的吻别
    2021-01-01 20:04

    I hadn't seen this before, so here's my guess: the internal storage of a StringBuilder appears to no longer be a simple string, but a set of 'chunks'. ToString can't return a reference to this internal string because it no longer exists.

    (Are version 4.0 StringBuilders now ropes?)

提交回复
热议问题