Search code examples
c#resharper.net-standard-2.0

String.Join overload not recognized


I have code equivalent to String.Join(',', new List<ulong>()) in a .NET Standard 2.0 project. I get two error from this line:

  1. Argument 1: cannot convert from 'char' to 'string'
  2. Argument 2: cannot convert from 'System.Collections.Generic.List<ulong>' to 'System.Collections.Generic.IEnumerable<string>'

These are the overloads of String.Join ReSharper shows on navigating to symbol:

enter image description here

I would assume that the second-last overload public static string Join<T>(char separator, IEnumerable<T> values); would be selected, but this doesn't happen.

When I changed my code to String.Join<ulong>(',', new List<ulong>()) (explicitly specifying the generic type), the second error disappeared. Am I doing something incorrectly or is this a bug in VS?


Solution

  • .NET Standard does not have String.Join overloads with char as a first parameter, only .NET Core has them.

    You have to use String.Join(",", new List<ulong>()).

    https://learn.microsoft.com/en-us/dotnet/api/system.string?view=netstandard-2.0

    Both R# and Rider show wrong info when navigating to symbol from .NET Core code, I can confirm this.