## Background and Motivation Many classes provide `AsSpan` methods and most provide at least the 3 basic methods, `AsSpan()`, `AsSpan(int start)`, `AsSpan(int start, int length)`. The `StringSegment` class only provides `AsSpan()`, but it should provide the other two for consistency and ease of use. ## Proposed API ```diff namespace Microsoft.Extensions.Primitives { public readonly struct StringSegment : IEquatable<StringSegment>, IEquatable<string> { public ReadOnlySpan<char> AsSpan(); + public ReadOnlySpan<char> AsSpan(int start); + public ReadOnlySpan<char> AsSpan(int start, int length); } } ``` ## Usage Examples ``` C# // input.AsSpan().Slice(startIndex, typeLength); input.AsSpan(startIndex, typeLength); ``` ## Alternative Designs No, other classes that provide `AsSpan` have similar overloads ## Risks None
Activity
bartonjs commentedon May 27, 2021
Video
Looks good as proposed.
gfoidl commentedon May 28, 2021
I'd like to add these overloads.