How to return list from method in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
   
class Program
{
    public static List<string> getList(string str1, string str2, string str3) {
        List<string> lst = new List<string>();
           
        lst.Add(str1);
        lst.Add(str2);
        lst.Add(str3);

        return lst;
    }
    static void Main() {
        List<string> result = getList("c#", "vb.net", "java");
   
        Console.WriteLine(string.Join(" ", result));
    }
}
   
   
   
   
/*
run:
   
c# vb.net java
   
*/

 



answered Jan 2, 2022 by avibootz

Related questions

1 answer 140 views
140 views asked Dec 13, 2020 by avibootz
1 answer 146 views
146 views asked Dec 12, 2020 by avibootz
1 answer 142 views
3 answers 351 views
1 answer 157 views
2 answers 225 views
1 answer 240 views
...