
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Convert Several Strings into a Single Comma Delimited String in C#
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
Advertisements