dotnet / dotnet/dotnet-api-docs

Could you specify what happens if source is already a List<T>

Open
#1,666 6 comments 0 reactions 0 assignees View on GitHub
area-System.Linq dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

I know that ToList() creates a shallow clone of the source, but is this guaranteed to be true for all versions of .NET? Sometimes I want to create a shallow clone of List<T> and I want to be certain that ToList() does that.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: a22a1d4d-3345-e3a4-e171-ccf602efbab8
* Version Independent ID: 4cfd3f7b-dfa8-3b0d-44d3-a251deab7b5b
* Content: [Enumerable.ToList(IEnumerable<TSource>) Method (System.Linq)](https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.tolist?view=netframework-4.7.2)
* Content Source: [xml/System.Linq/Enumerable.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Linq/Enumerable.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

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.