Trying out the new Spans for the first time and I was expecting ReadOnlySpan<char>.ToString() to be an easy way to do a conversion. It just returns the default type name.
I understand that ReadOnlySpan<T> is an array-like structure but with https://github.com/dotnet/corefx/issues/21395 coming ReadOnlySpan<char> is going to look string-like.
Is their any precedent to Something<char>.ToString() being special cased?
Span<T> is a too low level type to override ToString. There could be an extension method for ReadOnlySpan<char> but more practical approach would be to add another ctor tostring which will be taking ReadOnlySpan<char>
Handled by something around System.Text.Primitives?
Though not sure if outputing a string is in there? /cc @KrzysztofCwalina
@omariom I think it's a good idea to add the string ctor either way but to me the ToString() looks better. Closer to a StringBuilder than an array.
string a = myCharSpan.Trim().ToString();
string b = new String(myCharSpan.Trim());
It is not critical but a nice to have.
Don't think you can specifically override; or provide an extension method (as is defined instance method) for
Span<char>.ToString()
Would have to override Span<T>.ToString() then typeof(T) to get that effect
Span<char> is very much like array. char[].ToString() does not return the content as a string either.
Fair call 馃憤
Most helpful comment
Span<char>is very much like array.char[].ToString()does not return the content as a string either.