dotnet / dotnet/dotnet-api-docs
Detail about when capacity is increased
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
There's no detail explaining what happens when the internal array is resized - as I understand it, if the array isn't big enough, it creates a new array which is twice the size of the current one and copies the data. Although this is an implementation detail, I think it's interesting to note here, as it implies that using capacities that are powers of two would be more memory efficient than an arbitrary value.
---
#### Document Details
⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*
* ID: 95924f9e-2613-d2f4-6b2a-0ca31350b35b
* Version Independent ID: d9c109dc-6880-6f3f-9f82-ba52a53b664e
* Content: [List<T>.Capacity Property (System.Collections.Generic)](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.capacity?view=netframework-4.7.2#System_Collections_Generic_List_1_Capacity)
* Content Source: [xml/System.Collections.Generic/List`1.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Collections.Generic/List`1.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**
Contributor guide
Assessment
This issue has not been assessed yet.