String.Join不接受IEnumerable <string>

1 c# .net-3.5

我有一个带有此签名的方法:

IEnumerable<string> GetCombinations(string s, int length)
Run Code Online (Sandbox Code Playgroud)

我试图string.Join像这样使用它:

var combinations = GetCombinations(text, 2);
string result = string.Join(", ", combinations);
Run Code Online (Sandbox Code Playgroud)

但是我得到以下编译器错误:

cannot convert from 'System.Collections.Generic.IEnumerable<string>' to 'string[]'

不能string.Join拿一个IEnumerable<string>

Dan*_*n J 7

您使用的是什么版本的.NET Framework?在.NET 4中添加了接受IEnumerable而不是数组的String.Join重载.


Rob*_*III 5

打电话.TaArray吗?

String.Join(", ",combinations.ToArray());
Run Code Online (Sandbox Code Playgroud)

编辑

另请参阅Dan J的答案:自.Net 4以来,String.Join的重载确实接受了IEnumerable.