You can use String.Join
. If you have a List<string>
then you can call ToArray
first:
List<string> names = new List<string>() { "John", "Anna", "Monica" }; var result = String.Join(", ", names.ToArray());
In .NET 4 you don’t need the ToArray
anymore, since there is an overload of String.Join
that takes an IEnumerable<string>
.
Results:
John, Anna, Monica
Related Posts:
- Convert a list of strings to a single string
- How to initialize a list of strings (List
) with many string values - How can I convert String to Int?
- Convert int to string?
- Converting string to byte array in C#
- How to Sort a List
by a property in the object - How can I add ” character to a multi line string declaration in C#?
- finding the maximum length of lists in c#
- How can I find a specific element in a List
? - Check if list is empty in C#
- C#: how to get first char of a string?
- What does {0} mean when found in a string in C#?
- Select distinct using linq
- C# – Illegal characters in path
- Getting The ASCII Value of a character in a C# string
- Are 2 dimensional Lists possible in c#?
- IEnumerable vs List – What to Use? How do they work?
- How to easily initialize a list of Tuples?
- Merge two (or more) lists into one, in C# .NET
- How can I fix the error : “Unreachable Code Detected”
- C# – How to convert string to char?
- Converting from IEnumerable to List
- Escape double quotes in a string
- finding the maximum length of lists in c#
- How to split() a delimited string to a List
- Creating a comma separated list from IList
or IEnumerable - Fastest way to remove first char in a String
- Checking if a string array contains a value, and if so, getting its position
- Substring index and length must refer to a location within the string
- Case insensitive ‘Contains(string)’
- Most efficient way to remove special characters from string
- Is there an equivalent to the Scanner class in C# for strings?
- How to add List<> to a List<> in asp.net [duplicate]
- Adding a newline into a string in C#
- How to format a string as a telephone number in C#
- How to convert UTF-8 byte[] to string
- .NET String.Format() to add commas in thousands place for a number
- Sort list by field (C#)
- Remove duplicates from a List
in C# - How would you count occurrences of a string (actually a char) within a string?
- C# equivalent to Java’s charAt()?
- Linq select objects in list where exists IN (A,B,C)
- What is a quick way to force CRLF in C# / .NET?
- C# Convert List
to Dictionary - Check if a string is a palindrome
- How do I clone a generic list in C#?
- Convert string to decimal, keeping fractions
- Convert JSON String to JSON Object c#
- Convert an array to string
- Quickest way to compare two generic lists for differences
- Unrecognized escape sequence for path string containing backslashes
- Convert HTML to PDF in .NET
- How to show a loading gif while an APi is being called in xamarin android?
- ImageMagick creating blank transparent square(s) according to width
- .Net 4.8 Support for Windows 10 ends in 26 days?
- How do I generate a random int number?
- Why has the int32 type a maximum value of 2³¹ − 1? [duplicate]
- What is a NullReferenceException, and how do I fix it?
- How to convert list to string [duplicate]
- How do I get a random YouTube video with the YouTube API?
- An existing connection was forcibly closed by the remote host
- C# HttpClient An existing connection was forcibly closed by the remote host
- What is a NullReferenceException, and how do I fix it?
- What is a PDB file?
- What is the { get; set; } syntax in C#?
- Unexplained crashes related to ntdll.dll
- I am getting Failed to load resource: net::ERR_BLOCKED_BY_CLIENT with Google chrome
- How can I parse JSON with C#?
- Can anyone explain IEnumerable and IEnumerator to me? [closed]
- What is parsing?
- What is IP address ‘::1’?
- CS0120: An object reference is required for the nonstatic field, method, or property ‘foo’
- IOException: The process cannot access the file ‘file path’ because it is being used by another process
- How to find child of a GameObject or the script attached to child GameObject via script
- Process cannot access the file because it is being used by another proess
- Getting mouse position in unity
- Error : Index was outside the bounds of the array.
- How to fix “HTTP Error 400. The size of the request headers is too long” error from azure cloud services?
- C# error: “An object reference is required for the non-static field, method, or property”
- No connection could be made because the target machine actively refused it?
- How to convert JSON to XML or XML to JSON?
- Virustotal Trapmine suspicious.low.ml.score
- What is the difference between declarative and imperative paradigm in programming?
- How to fix No connection could be made because the target machine actively refused it 127.0.0.1:64527
- Could not load file or assembly or one of its dependencies
- What does a lock statement do under the hood?
- How to make the script wait/sleep in a simple way in unity
- What is the yield keyword used for in C#?
- Error : Could not load file or assembly or one of it’s dependencies
- Group by in LINQ
- Join/Where with LINQ and Lambda
- Could not load file or assembly or one of its dependencies
- All possible array initialization syntaxes
- Adding values to a C# array
- C# compiler error: “not all code paths return a value”
- Multiline string literal in C#
- What is C# equivalent of
- How to use SQLite in Visual Studio 2017?
- Algorithms in O(n^2) vs O(n) [duplicate]
- Unity OnTriggerEnter2D not registering