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 252 views
1 answer 424 views
1 answer 459 views
5 answers 585 views
5 answers 496 views
...