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
- C# HttpClient An existing connection was forcibly closed by the remote host
- Error : Index was outside the bounds of the array.
- No connection could be made because the target machine actively refused it?
- What does a lock statement do under the hood?
- What is C# equivalent of
- Why is this code throwing an InvalidOperationException?
- How to add a default Default.aspx to a ASP.NET Web Application Project?
- Regex for numbers only
- Access to the path is denied
- What does question mark and dot operator ?. mean in C# 6.0?
- How to jump in Unity 3d?
- Incorrect string value: ‘\xEF\xBF\xBD’ for column
- How do I declare a DefaultValue attribute whose value is an array of strings?
- Unity3d restart current scene
- Easiest way to alter eBay page content/DOM
- Why does var evaluate to System.Object in “foreach (var row in table.Rows)”?
- MSHTML DLL on Windows 10
- ..The underlying connection was closed: An unexpected error occurred on a receive
- What are Virtual Methods?
- SQL Insert Query Using C#
- How to round up the result of integer division?
- Read and parse a Json File in C#
- How to declare session variable in C#?
- Cannot open database “test” requested by the login. The login failed. Login failed for user ‘xyz\ASPNET’
- Writing data into CSV file in C#
- System.Data.SqlClient.SqlException: Login failed for user
- What’s the @ in front of a string in C#?
- C# Print list of string array
- “A project with an Output type of Class Library cannot be started directly”
- entity object cannot be referenced by multiple instances of IEntityChangeTracker. while adding related objects to entity in Entity Framework 4.1
- What does ModelState.IsValid do?
- When to use an Enum vs Struct
- How to make a simple popup box in Visual C#?
- windows could not start service on local computer error 5 access is denied
- Destroy an object in C#
- How can we generate getters and setters in Visual Studio?
- Fastest way to generate a random boolean
- need implement C# Counter
- Invalid attempt to read when no data is present
- convert string to arraylist
in java - Is there a way to toggle a boolean variable in C#?
- Effectively use async/await with ASP.NET Web API
- A potentially dangerous Request.Path value was detected from the client (*)
- Get single listView SelectedItem
- .NET Core vs Mono
- Add item to Listview control
- Windows service start failure: Cannot start service from the command line or debugger [duplicate]
- Displaying DateTime picker instead of Date picker in ASP .NET MVC 5.1/HTML 5 specific