I have a method with this signature:
IEnumerable<string> GetCombinations(string s, int length)
And I am trying to use it with string.Join like this:
var combinations = GetCombinations(text, 2);
string result = string.Join(", ", combinations);
But I get the following compiler error:
cannot convert from 'System.Collections.Generic.IEnumerable<string>' to 'string[]'
Can't string.Join take an IEnumerable<string>?
Call .ToArray on it?
String.Join(", ",combinations.ToArray());
EDIT
Also see Dan J's answer: Since .Net 4 an overload of String.Join does accept an IEnumerable.
What version of the .NET Framework are you using? The overload of String.Join that accepts an IEnumerable instead of an array was added in .NET 4.