Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Added note that this is just for .Net 4.0 and above, thanks to Derek's comment
Source Link

I think that the cleanest way to create a comma-separated list of string values is simply:

string.Join<string>(",", stringEnumerable); 

Here is a full example:

IEnumerable<string> stringEnumerable= new List<string>(); stringList.Add("Comma"); stringList.Add("Separated"); string.Join<string>(",", stringEnumerable); 

There is no need to make a helper function, this is built into .NET 4.0 and above.

I think that the cleanest way to create a comma-separated list of string values is simply:

string.Join<string>(",", stringEnumerable); 

Here is a full example:

IEnumerable<string> stringEnumerable= new List<string>(); stringList.Add("Comma"); stringList.Add("Separated"); string.Join<string>(",", stringEnumerable); 

There is no need to make a helper function, this is built into .NET

I think that the cleanest way to create a comma-separated list of string values is simply:

string.Join<string>(",", stringEnumerable); 

Here is a full example:

IEnumerable<string> stringEnumerable= new List<string>(); stringList.Add("Comma"); stringList.Add("Separated"); string.Join<string>(",", stringEnumerable); 

There is no need to make a helper function, this is built into .NET 4.0 and above.

Source Link

I think that the cleanest way to create a comma-separated list of string values is simply:

string.Join<string>(",", stringEnumerable); 

Here is a full example:

IEnumerable<string> stringEnumerable= new List<string>(); stringList.Add("Comma"); stringList.Add("Separated"); string.Join<string>(",", stringEnumerable); 

There is no need to make a helper function, this is built into .NET