Skip to content

[Syntax Deficiency] C# syntax does not accept Span<char> or ReadOnlySpan<char> as valid values with ToString() methods #1758

Discussion options

You must be logged in to vote

@4creators

String interpolation doesn't call ToString, it passes the argument to an API that expects object. What that API happens to do with the argument is completely opaque and subject to formatters and the like. To have C# explicitly call ToString for Span<T> or other ref structs would change the expectation of what that feature does. You can work around this today by calling ToString yourself.

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by YairHalberstadt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #1758 on October 18, 2020 07:50.