Skip to content

Add primitive type Span-based Parse/TryParse/TryFormat methods #22837

@stephentoub

Description

@stephentoub

Separated out of https://github.com/dotnet/corefx/issues/21281 for tracking purposes.

  • Implement parsing in System.Private.CoreLib in coreclr
  • Implement parsing in System.Private.CoreLib in corert (unless primitive types are "shared" by then)
  • Expose parsing from System.Runtime contract in corefx
  • Add parsing tests to System.Runtime tests in corefx
  • Implement formatting in System.Private.CoreLib in coreclr
  • Implement formatting in System.Private.CoreLib in corert (unless primitive types are "shared" by then)
  • Expose formatting from System.Runtime contract in corefx
  • Add formatting tests to System.Runtime tests in corefx
namespace System
{
    public struct Int16
    {
        public short Parse(ReadOnlySpan<char> s, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null);
        public bool TryParse(ReadOnlySpan<char> s, out short result, NumberStyles style = NumberStyles.Integer, IFormatProvider provider = null);

        public bool TryFormat(Span<char> destination, out int charsWritten, string format = null, IFormatProvider provider = null);}// similar Parse/TryParse/TryFormat methods for each of:
    // Int32
    // Int64
    // UInt16
    // UInt32
    // UInt64
    // Decimal
    // Double
    // Single
    // Boolean (but no NumberStyle/NumberFormatInfo args)
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions