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
How to convert a list to string in C#?
Declare a list.
List < string > l = new List < string > ();
Now, add elements to the list.
// elements
l.Add("Accessories");
l.Add("Footwear");
l.Add("Watches");
Now convert it into a string.
string str = string.Join(" ", l.ToArray());
Let us see the final code to convert a list to string in C# −
Example
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
List < string > l = new List < string > ();
// elements
l.Add("Accessories");
l.Add("Footwear");
l.Add("Watches");
string str = string.Join(" ", l.ToArray());
Console.WriteLine(str);
}
}Advertisements