How to get a comma separated string from an array in C#?
Ask by Ravi Vishwakarma
Updated 11 Jun 2024
You can use the
string.Join()method to concatenate the elements of an array into a single string, with each element separated by a specified delimiter, such as a comma, semi-colon, hyphen, etc.Here's how you can do it:
string.Join()takes two parameters: the separator (", " in this case) and the array of strings to join. It returns a single string containing all the elements of the array separated by the specified separator.Output -