I'm trying to combine List<string> strings using string.Join(",", strings) but everything I'm reading says I should do:
string.Join(",", strings.ToArray())
Is there a certain reason I have to/should use .ToArray()?
string.Join only started accepting IEnumerable<string> (and indeed a generic overload) as of .NET 4. Presumably you're looking at code (or instructions) written with .NET 3.5 or earlier in mind. Compare the overloads:
string.Join in .NET 3.5string.Join in .NET 4Probably because everything you're reading was written for an earlier version of the framework.  The string.Join(string, IEnumerable<string>) method was added in version 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With