Skip to content

Add implicit cast from string to ReadOnlySpan<char> #24208

@stephentoub

Description

@stephentoub

Proposal:

public class String
{
    public static implicit operator ReadOnlySpan<char>(string value) =>
        value != null ? new ReadOnlySpan<char>(ref value.GetRawStringData(), value.Length) : default;
    ...
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions