How to initialize a list of strings inline in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
    
class Program
{
    static void Main() {
        var list = new List<string> { "python", "c#", "c", "c++", "java", "php", "go" };

         Console.WriteLine(string.Join(" ", list));
    }
}
    
    
    
    
/*
run:
       
python c# c c++ java php go
     
*/

 



answered Aug 11, 2023 by avibootz

Related questions

1 answer 169 views
1 answer 328 views
1 answer 348 views
5 answers 394 views
5 answers 324 views
1 answer 149 views
149 views asked Jan 14, 2024 by avibootz
...