Skip to content

[Api Proposal] Add List<T> AsSpan to CollectionsMarshal #27061

@benaadams

Description

@benaadams

Its not a "safe" operation, though it is a useful one to gain access to the prebuilt array; without first copying using .ToArray()

namespace System.Runtime.InteropServices
{
    public partial static class CollectionsMarshal
    {
        public Span<T> AsSpan(List<T> list);
        public Memory<T> AsMemory(List<T> list);
    }
}

/cc @jkotas

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions