How to Get a Comma Separated String From an Array in C#? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report Given an array, now our task is to get a comma-separated string from the given array. So we can do this task using String.Join() method. This method concatenates the items of an array with the help of a comma separator between each item of the array. Syntax: String.Join(",", array_name)Where array_name is the input array. Example: Input: {"sireesha", "priyank", "ojaswi", "gnanesh"} Output: sireesha,priyank,ojaswi,gnanesh Input: {"sireesha", "priyank"} Output: sireesha,priyankApproach 1: Declare an array of strings.Use the string join() function to get the comma separated strings.String.Join(",", names)Display the final result.Example: C# // C# program to display the comma separated // string from an array using System; class GFG{ public static void Main() { // Creating an array of string elements String[] names = { "sireesha", "priyank", "ojaswi", "gnanesh" }; // Join the elements separated by comma // Using Join() method var str1 = String.Join(",", names); // Display the final string Console.WriteLine(str1); } } Output: sireesha,priyank,ojaswi,gnaneshApproach 2: We can also find the command-separated string from the object array. Create a class named MyEmployee with First_Name and Last_Name methods.Declare object array of MyEmployee in the main method.Use string join() function to get the comma separated strings.String.Join(",", e.Select(m => m.First_Name)); Here, we only join the first name so we use the select method to select the First_Name of the employees. Display the final result. Example 2: C# // C# program to display the comma separated // string from an array using System; using System.Linq; // MyEmployee class class MyEmployee { public string First_Name { get; set; } public string Last_Name { get; set; } } class GFG{ public static void Main() { // Creating object array of MyEmployee MyEmployee[] e = { new MyEmployee(){ First_Name = "Sumi", Last_Name = "Goyal" }, new MyEmployee(){ First_Name = "Mohan", Last_Name = "Priya" }, new MyEmployee(){ First_Name = "Sumit", Last_Name = "Singh" } }; // Join the elements separated by comma // Using Join() method var res = String.Join(",", e.Select(m => m.First_Name)); // Display the final result Console.WriteLine("Final String:" + res); } } Output: Final String:Sumi,Mohan,Sumit Comment More infoAdvertise with us Next Article Class Diagram | Unified Modeling Language (UML) S sireeshakanneganti112 Follow Improve Article Tags : C# C# Programs CSharp-Arrays-Programs CSharp-Strings-Programs Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i 6 min read Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc 15+ min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca 7 min read What is an Operating System? An Operating System is a System software that manages all the resources of the computing device. Acts as an interface between the software and different parts of the computer or the computer hardware. Manages the overall resources and operations of the computer. Controls and monitors the execution o 5 min read CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi 6 min read Python Functions Python Functions is a block of statements that does a specific task. The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the same code again and again for different inputs, we can do the function calls to reuse code contained in it over an 9 min read Like