---
source: https://iinventedlight.com/library/notes/csharp-collections.md
title: ".NET collections and C# collection expressions"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (dotnet/docs); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn (.NET docs), Collections and Data Structures - .NET, CC BY 4.0 (dotnet/docs); Microsoft Learn (.NET docs), Collection expressions (Collection literals) - C# reference, CC BY 4.0 (dotnet/docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: C# and .NET"
tags: csharp, dotnet, collections
sources:
  - id: S1
    title: "Collections and Data Structures - .NET"
    publisher: Microsoft Learn (.NET docs)
    url: https://learn.microsoft.com/en-us/dotnet/standard/collections/
    accessed: 2026-11-04
    license: "CC BY 4.0 (dotnet/docs)"
  - id: S2
    title: "Collection expressions (Collection literals) - C# reference"
    publisher: Microsoft Learn (.NET docs)
    url: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/collection-expressions
    accessed: 2026-11-04
    license: "CC BY 4.0 (dotnet/docs)"
---
# .NET collections and C# collection expressions

## Short answer
Use a collection expression to create common collection values. (S2)

```csharp
List<int> nums = [1, 2, 3];
int[] all = [.. nums, 4, 5]; // spread
```

## Key points
- They don't require that you cast to and from the Object type when you add or remove items from the collection. (S1)
- You can't use collection expressions to initialize inline arrays. (S2)

## Claims
- id: C1
  claim: In general you should use generic collections.
  source: S1
  evidence: "In general, you should use generic collections."
- id: C2
  claim: System.Collections.Concurrent provides thread-safe collection operations.
  source: S1
  evidence: "provide efficient thread-safe operations for accessing collection items"
- id: C3
  claim: A collection expression is a terse syntax for many collection types.
  source: S2
  evidence: "A collection expression is a terse syntax that you can assign to many different collection"
- id: C4
  claim: A spread element .. inlines collection values.
  source: S2
  evidence: "Use a spread element .. to inline collection values in a collection expression."

## Sources
- [S1] Collections and Data Structures - .NET. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/standard/collections/ . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.
- [S2] Collection expressions (Collection literals) - C# reference. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/collection-expressions . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
