1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 using System
.Collections
.Generic
;
7 namespace System
.Runtime
.InteropServices
10 /// An unsafe class that provides a set of methods to access the underlying data representations of collections.
12 public static class CollectionsMarshal
15 /// Get a <see cref="Span{T}"/> view over a <see cref="List{T}"/>'s data.
16 /// Items should not be added or removed from the <see cref="List{T}"/> while the <see cref="Span{T}"/> is in use.
18 public static Span
<T
> AsSpan
<T
>(List
<T
>? list
)
19 => list
is null ? default : new Span
<T
>(list
._items
, 0, list
._size
);