Collection literals produce ambiguous call to methods accepting char[]
and string?
#95548
-
I'm exposing the following methods in my NuGet library. public ParsedFile(string path, char[] existingSeparator, bool ignoreEmptyItems = true) {}
public ParsedFile(string path, string? existingSeparator = null, bool ignoreEmptyItems = true) {} But I just realized I can't call it using the new collection literals: new ParsedFile(InputFilePath, [ ';', ':' ]); or I get CS0121 compiler error: ambiguous call. So I need to stick to invoking it like this: new ParsedFile(InputFilePath, new[] { ';', ':' }) I still want to allow users to define either a string as a separator (i.e. "//") or a number of different chars (i.e. What's my best option, maintainability wise, when moving forward with the API? Thanks 😀 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is expected. See dotnet/roslyn#70831 . |
Beta Was this translation helpful? Give feedback.
This is expected. See dotnet/roslyn#70831 .
The language team is going to explore this in next version.