
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to convert several strings into a single comma-delimited string
Set the strings −
List<string> val = new List<string>(); // list of strings val.Add("water"); val.Add("food"); val.Add("air");
Use Join method to convert several strings into a single comma-delimited string −
string.Join(",", val.ToArray());
Here is the complete code −
Example
using System; using System.Collections.Generic; public class Demo { public static void Main() { List<string> val = new List<string>(); // list of strings val.Add("water"); val.Add("food"); val.Add("air"); string res = string.Join(",", val.ToArray()); Console.WriteLine(res); } }
Output
water,food,air
- Related Questions & Answers
- Parsing a comma-delimited std::string in C++
- PHP program to split a given comma delimited string into an array of values
- How to collapse rows into a comma-delimited list with a single MySQL Query?
- MySQL select distinct rows into a comma delimited list column?
- Combining multiple rows into a comma delimited list in MySQL?
- Convert String into comma separated List in Java
- How to convert a comma separated String into an ArrayList in Java?
- Java Program to Convert a List of String to Comma Separated String
- C# program to convert a list of characters into a string
- How to convert list elements into a single string in R?
- How to join two strings to convert to a single string in Python?
- Replacing numbers on a comma delimited result with MySQL?
- Java Program to Convert a String into the InputStream
- Convert JavaScript array iteration result into a single line text string
- How to convert a single char into an int in C++
Advertisements