How to get a comma separated string from an array in C#?
289
11-Jun-2024
Home / DeveloperSection / Interviews / How to get a comma separated string from an array in C#?
Ravi Vishwakarma
11-Jun-2024You 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 -