© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
53 replies
ikalou.

List, Collection Initializer and Capacity

Hi! Does creating a new List with new List<T> { new T() } (or any number of elements > 0) starts with the proper capacity in order to avoid resizes or does it start at 0 and then grows to add the elements and I should be using new List<T>(1) { new T() } (for instance) instead? Thanks for helping me figure this out!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

❔ Null class auto initializer
C#CC# / help
4y ago
❔ Error. Array initializer can only be used in a variable or field initializer.
C#CC# / help
4y ago
Nongeneric interfaces and collection classes
C#CC# / help
11mo ago
Concurrent collection type similar to Dictionary<TKey, List<TValue>>
C#CC# / help
7mo ago