csharp program that joins List of strings

Code Example - csharp program that joins List of strings

                
                        using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        // Create a List of 3 strings.
        var list = new List<string>() { "cat", "dog", "rat" };
        // Join the strings from the List.
        string joined = string.Join<string>("*", list);
        // Display.
        Console.WriteLine(joined);
    }
}
                    
                
 

csharp list join

                        
                                List<string> names = new List<string>() { "John", "Anna", "Monica" };
var result = String.Join(", ", names.ToArray());
                            
                        
 

csharp join string array

                        
                                var combined = String.Join(",", new String[]{"a","b"});
// a,b