I have a NetStandard2.0 class library. I have imported the System.Memory nuget package, which means I can use Span<T> inside it. That's well and good, but the nuget package doesn't seem to include the ReadOnlySpan<char> overloads for StringBuilder and the TryParse() methods for other primitive types.

If I could upgrade to netstandard21, I would do that, and this problem would go away, but I can't for reasons beyond my control.

This code works in a netcoreapp2.2 program, but not a netstandard20 class library, even with System.Memory as a dependency:

public static int GetIbanIntValueForCharacter(ReadOnlySpan<char> span)
{
    // Stuff

    if (int.TryParse(span, out var val))
    {
        return val;
    }

    // More stuff
}

Is there another nuget package that I can reference that brings span support to StringBuilder and TryParse to netstandard20 libraries?

0

There are 0 best solutions below