dotnet / dotnet/dotnet-api-docs

Why the StringBuilder object is chunky even after the data from the original buffer is copied to the new buffer?

Open
#2,338 2 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

https://github.com/dotnet/dotnet-api-docs/blob/7668d4bac38aff3ce335fed5c840cdd6730edf5a/xml/System.Text/StringBuilder.xml#L87

Hi,
1. The buffer of the StringBuilder object will be extended automatically and the data of the original buffer will be coped to the new buffer.
![QQ截图20190418120008](https://user-images.githubusercontent.com/13234209/56336116-aa9d3780-61d1-11e9-85d6-67449f9c5ce7.jpg)
2. Why the StringBuilder object is "chunky"?
There is always a continuous buffer but not chunky as the buffer will be extended automatically.
3. Why the Chars[int32] property is not O(1)?
The buffer is continuous, so, Chars[int32] property is O(1).
![QQ截图20190418115941](https://user-images.githubusercontent.com/13234209/56336258-3d3dd680-61d2-11e9-8ba1-69e95a1f6a8e.jpg)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.