---
title: "How to get a comma separated string from an array in C#?"  
description: "How to get a comma separated string from an array in C#?"  
author: "Ravi Vishwakarma"  
published: 2024-06-11  
updated: 2024-06-11  
canonical: https://www.mindstick.com/interview/33902/how-to-get-a-comma-separated-string-from-an-array-in-c-sharp  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 2 minutes  

---

# How to get a comma separated string from an array in C#?

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:

```cs
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Sample array
            string[] array = { "apple", "banana", "orange", "grape" };

            // Joining array elements with a comma separator
            string result = string.Join(", ", array);

            // Displaying the result
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}
```

`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 -

```cs
apple, banana, orange, grape
```

## Answers

### Answer by Ravi Vishwakarma

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:

```cs
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Sample array
            string[] array = { "apple", "banana", "orange", "grape" };

            // Joining array elements with a comma separator
            string result = string.Join(", ", array);

            // Displaying the result
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}
```

`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 -

```cs
apple, banana, orange, grape
```


---

Original Source: https://www.mindstick.com/interview/33902/how-to-get-a-comma-separated-string-from-an-array-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
