String.Join 无法识别过载
String.Join overload not recognized
我在 .NET Standard 2.0 项目中有等同于 String.Join(',', new List<ulong>())
的代码。我从这一行得到两个错误:
Argument 1: cannot convert from 'char' to 'string'
Argument 2: cannot convert from 'System.Collections.Generic.List<ulong>' to 'System.Collections.Generic.IEnumerable<string>'
这些是 String.Join ReSharper 在导航到符号时显示的重载:
我假设会选择倒数第二个重载 public static string Join<T>(char separator, IEnumerable<T> values);
,但这并没有发生。
当我将代码更改为 String.Join<ulong>(',', new List<ulong>())
(明确指定泛型类型)时,第二个错误消失了。我做错了什么或者这是 VS 中的错误吗?
.NET Standard 没有 String.Join
以 char
作为第一个参数的重载,只有 .NET Core 有它们。
你必须使用 String.Join(",", new List<ulong>())
.
https://docs.microsoft.com/en-us/dotnet/api/system.string?view=netstandard-2.0
从 .NET Core 代码导航到符号时,R# 和 Rider 都显示错误信息,我可以确认这一点。
.NET Standard 2.0 没有第一个参数为 char 类型的重载。所有 string.Join
重载都有字符串类型的第一个参数?
似乎 Resharper 向您显示的是 netstandard 2.0 的实现,而不是合同。
public static System.String Join(System.String separator, System.Collections.Generic.IEnumerable<string> values) { throw null; }
public static System.String Join(System.String separator, params object[] values) { throw null; }
public static System.String Join(System.String separator, params string[] value) { throw null; }
public static System.String Join(System.String separator, string[] value, int startIndex, int count) { throw null; }
public static System.String Join<T>(System.String separator, System.Collections.Generic.IEnumerable<T> values) { throw null; }
我在 .NET Standard 2.0 项目中有等同于 String.Join(',', new List<ulong>())
的代码。我从这一行得到两个错误:
Argument 1: cannot convert from 'char' to 'string'
Argument 2: cannot convert from 'System.Collections.Generic.List<ulong>' to 'System.Collections.Generic.IEnumerable<string>'
这些是 String.Join ReSharper 在导航到符号时显示的重载:
我假设会选择倒数第二个重载 public static string Join<T>(char separator, IEnumerable<T> values);
,但这并没有发生。
当我将代码更改为 String.Join<ulong>(',', new List<ulong>())
(明确指定泛型类型)时,第二个错误消失了。我做错了什么或者这是 VS 中的错误吗?
.NET Standard 没有 String.Join
以 char
作为第一个参数的重载,只有 .NET Core 有它们。
你必须使用 String.Join(",", new List<ulong>())
.
https://docs.microsoft.com/en-us/dotnet/api/system.string?view=netstandard-2.0
从 .NET Core 代码导航到符号时,R# 和 Rider 都显示错误信息,我可以确认这一点。
.NET Standard 2.0 没有第一个参数为 char 类型的重载。所有 string.Join
重载都有字符串类型的第一个参数?
似乎 Resharper 向您显示的是 netstandard 2.0 的实现,而不是合同。
public static System.String Join(System.String separator, System.Collections.Generic.IEnumerable<string> values) { throw null; }
public static System.String Join(System.String separator, params object[] values) { throw null; }
public static System.String Join(System.String separator, params string[] value) { throw null; }
public static System.String Join(System.String separator, string[] value, int startIndex, int count) { throw null; }
public static System.String Join<T>(System.String separator, System.Collections.Generic.IEnumerable<T> values) { throw null; }