Alex Rivera | Logout

Why is ToArray() used when using string.Join with a List<string>?

Asked 2012-04-10T16:38:07.450
8

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()?

c#
Edit
Report

1 Answer

5

Probably 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.

answered 2012-04-10T16:40:25.697

Your Answer